add libraries
This commit is contained in:
parent
ca8ed709b8
commit
9c9f795b2f
33
.cproject
33
.cproject
@ -1,7 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="it.baeyens.arduino.core.toolChain.release.400069008">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="it.baeyens.arduino.core.toolChain.release.400069008" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
@ -22,22 +20,17 @@
|
||||
<tool id="it.baeyens.arduino.tool.sketch.compiler.cpp.442521309" name="Arduino C++ Compiler" superClass="it.baeyens.arduino.tool.sketch.compiler.cpp">
|
||||
<option id="it.baeyens.arduino.compiler.cpp.sketch.option.incpath.1534135165" name="Include Paths (-I)" superClass="it.baeyens.arduino.compiler.cpp.sketch.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/arduino/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Libraries/Ethernet}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Libraries/Ethernet/utility}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Libraries/EEPROM}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Libraries/Streaming}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Ethernet}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Ethernet/utility}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/EEPROM}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Streaming}""/>
|
||||
</option>
|
||||
<inputType id="it.baeyens.arduino.compiler.cpp.sketch.input.1988694850" name="CPP source files" superClass="it.baeyens.arduino.compiler.cpp.sketch.input"/>
|
||||
</tool>
|
||||
<tool id="it.baeyens.arduino.tool.compiler.c.1177223344" name="Arduino C Compiler" superClass="it.baeyens.arduino.tool.compiler.c">
|
||||
<option id="it.baeyens.arduino.compiler.c.sketch.option.incpath.420249303" name="Include Paths (-I)" superClass="it.baeyens.arduino.compiler.c.sketch.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/arduino/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Libraries/Ethernet}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Libraries/Ethernet/utility}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Libraries/EEPROM}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/NetMeterBusMaster2/Libraries/Streaming}""/>
|
||||
</option>
|
||||
<inputType id="it.baeyens.arduino.compiler.c.sketch.input.1905071279" name="C Source Files" superClass="it.baeyens.arduino.compiler.c.sketch.input"/>
|
||||
</tool>
|
||||
@ -46,10 +39,15 @@
|
||||
<tool id="it.baeyens.arduino.tool.objcopy.eep.2038346519" name="Arduino tool Create eeprom" superClass="it.baeyens.arduino.tool.objcopy.eep"/>
|
||||
<tool id="it.baeyens.arduino.tool.objcopy.flash.1009260605" name="Arduino tool Create hex" superClass="it.baeyens.arduino.tool.objcopy.flash"/>
|
||||
<tool id="it.baeyens.arduino.tool.size.2023431554" name="Arduino tool Print Size" superClass="it.baeyens.arduino.tool.size"/>
|
||||
<tool id="it.baeyens.arduino.tool.sketch.compiler.s.681983130" name="Arduino Assembler" superClass="it.baeyens.arduino.tool.sketch.compiler.s"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="Libraries/*/?xamples" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
|
||||
<entry excluding="EEPROM|Streaming|SPI|Ethernet|Libraries/*/?xamples" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="EEPROM"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Ethernet"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="SPI"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Streaming"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
@ -63,5 +61,10 @@
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Release">
|
||||
<resource resourceType="PROJECT" workspacePath="/NetMeterBusMaster2"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
</cproject>
|
||||
|
26
.project
26
.project
@ -26,26 +26,6 @@
|
||||
<nature>it.baeyens.arduinonature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>Libraries/EEPROM</name>
|
||||
<type>2</type>
|
||||
<locationURI>ArduinoHardwareLibPath/EEPROM</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Libraries/Ethernet</name>
|
||||
<type>2</type>
|
||||
<locationURI>ArduinoHardwareLibPath/Ethernet</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Libraries/SPI</name>
|
||||
<type>2</type>
|
||||
<locationURI>ArduinoHardwareLibPath/SPI</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Libraries/Streaming</name>
|
||||
<type>2</type>
|
||||
<locationURI>ArduinoPivateLibPath/Streaming</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>arduino/core</name>
|
||||
<type>2</type>
|
||||
@ -55,15 +35,15 @@
|
||||
<variableList>
|
||||
<variable>
|
||||
<name>ArduinoHardwareLibPath</name>
|
||||
<value>file:/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/all/libraries</value>
|
||||
<value>file:/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/avr/libraries</value>
|
||||
</variable>
|
||||
<variable>
|
||||
<name>ArduinoPinPath</name>
|
||||
<value>file:/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/all/variants</value>
|
||||
<value>file:/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/avr/variants</value>
|
||||
</variable>
|
||||
<variable>
|
||||
<name>ArduinoPlatformPath</name>
|
||||
<value>file:/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/all</value>
|
||||
<value>file:/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/avr</value>
|
||||
</variable>
|
||||
</variableList>
|
||||
</projectDescription>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<configuration id="it.baeyens.arduino.core.toolChain.release.400069008" name="Release">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider class="it.baeyens.arduino.toolchain.ArduinoLanguageProvider" console="false" env-hash="-2011256820" id="it.baeyens.arduino.languageSettingsProvider" keep-relative-paths="false" name="Arduino Compiler Settings" parameter="${COMMAND} -E -P -v -dD ${INPUTS}" prefer-non-shared="true">
|
||||
<provider class="it.baeyens.arduino.toolchain.ArduinoLanguageProvider" console="false" env-hash="631094806828645103" id="it.baeyens.arduino.languageSettingsProvider" keep-relative-paths="false" name="Arduino Compiler Settings" parameter="${COMMAND} -E -P -v -dD ${INPUTS}" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
@ -1,19 +1,16 @@
|
||||
eclipse.preferences.version=1
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.ARCHITECTURE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.ARCHITECTURE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.ARCHITECTURE/value=all
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.ARCHITECTURE/value=avr
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.ARCHIVE_FILE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.ARCHIVE_FILE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.ARCHIVE_FILE/value=teensy.ar
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BOOTLOADER.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BOOTLOADER.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BOOTLOADER.PATH/value=undefined
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.ARCHIVE_FILE/value=arduino.ar
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.ARCH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.ARCH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.ARCH/value=ALL
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.ARCHITECTURE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.ARCHITECTURE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.ARCHITECTURE/value=arm-none-eabi
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.ARCH/value=AVR
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.BOARD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.BOARD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.BOARD/value=TEENSY31
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.COMMAND.AR/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.COMMAND.AR/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.COMMAND.AR/value=arm-none-eabi-ar
|
||||
@ -32,168 +29,126 @@ environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.COMMAND.SIZE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.COMMAND.SIZE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.COMMAND.SIZE/value=arm-none-eabi-size
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CORE.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CORE.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CORE.PATH/value=${A.RUNTIME.PLATFORM.PATH}/cores/${A.BUILD.CORE}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CORE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CORE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CORE/value=teensy3
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CPPOPTION1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CPPOPTION1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CPPOPTION1/value=-fno-rtti
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CPU/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CPU/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.CPU/value=cortex-m4
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.DEFINE0/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.DEFINE0/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.DEFINE0/value=-DUSB_SERIAL
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.DEFINE1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.DEFINE1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.DEFINE1/value=-DLAYOUT_US_ENGLISH
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.DEPENDENCY/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.DEPENDENCY/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.DEPENDENCY/value=true
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.ELIDE_CONSTRUCTORS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.ELIDE_CONSTRUCTORS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.ELIDE_CONSTRUCTORS/value=true
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.EXTRA_FLAGS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.EXTRA_FLAGS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.EXTRA_FLAGS/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.F_CPU/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.F_CPU/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.F_CPU/value=24000000
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.GNU0X/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.GNU0X/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.GNU0X/value=true
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.LDSCRIPT/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.LDSCRIPT/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.LDSCRIPT/value=teensy/all/cores/teensy3/mk20dx256.ld
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.LINKOPTION1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.LINKOPTION1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.LINKOPTION1/value=-mthumb
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.LINKSCRIPT/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.LINKSCRIPT/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.LINKSCRIPT/value=mk20dx256.ld
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FCPU/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FCPU/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FCPU/value=72000000
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.C/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.C/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.C/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.COMMON/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.COMMON/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.COMMON/value=-g -Wall -ffunction-sections -fdata-sections -MMD -nostdlib
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.CPP/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.CPP/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.CPP/value=-fno-exceptions -felide-constructors -std\=gnu++0x -fno-rtti
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.CPU/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.CPU/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.CPU/value=-mthumb -mcpu\=cortex-m4
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.DEFS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.DEFS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.DEFS/value=-D__MK20DX256__ -DTEENSYDUINO\=121
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.LD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.LD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.LD/value=-Wl,--gc-sections,--relax,--defsym\=__rtc_localtime\=${A.EXTRA.TIME.LOCAL} "-T${A.BUILD.CORE.PATH}/mk20dx256.ld"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.LDSPECS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.LDSPECS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.LDSPECS/value=--specs\=nano.specs
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.LIBS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.LIBS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.LIBS/value=-larm_cortexM4l_math -lm
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.OPTIMIZE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.OPTIMIZE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.OPTIMIZE/value=-Os
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.S/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.S/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.FLAGS.S/value=-x assembler-with-cpp
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.KEYLAYOUT/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.KEYLAYOUT/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.KEYLAYOUT/value=GERMAN_MAC
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.MCU/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.MCU/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.MCU/value=cortex-m4
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.NOARCHIVE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.NOARCHIVE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.NOARCHIVE/value=true
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.OPTION1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.OPTION1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.OPTION1/value=-mthumb
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.OPTION2/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.OPTION2/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.OPTION2/value=-nostdlib
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.OPTION3/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.OPTION3/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.OPTION3/value=-D__MK20DX256__
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.MCU/value=mk20dx256
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.PATH/value=${ProjDirPath}/${ConfigName}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.POST_COMPILE_SCRIPT/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.POST_COMPILE_SCRIPT/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.POST_COMPILE_SCRIPT/value=teensy_post_compile
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.PROJECT_NAME/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.PROJECT_NAME/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.PROJECT_NAME/value=${ProjName}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.TIME_T/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.TIME_T/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.TIME_T/value=true
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.TOOLCHAIN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.TOOLCHAIN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.TOOLCHAIN/value=hardware/tools/arm/bin/
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.USBTYPE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.USBTYPE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.USBTYPE/value=USB_SERIAL
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.USE_ARCHIVER/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.USE_ARCHIVER/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.USE_ARCHIVER/value=false
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.USE_ARCHIVER/value=true
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.VARIANT.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.VARIANT.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.VARIANT.PATH/value=/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/all/variants/${A.BUILD.VARIANT}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.BUILD.VARIANT.PATH/value=${A.RUNTIME.PLATFORM.PATH}/variants/${A.BUILD.VARIANT}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CMD.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CMD.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CMD.PATH/value=${A.TOOLS.AVRDUDE.CMD.PATH}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CMD.PATH/value=${A.TOOLS.TEENSYLOADER.CMD.PATH}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CMD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CMD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CMD/value=${A.TOOLS.BOSSAC.CMD}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.AR.CMD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.AR.CMD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.AR.CMD/value=avr-ar
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.AR.FLAGS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.AR.FLAGS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.AR.FLAGS/value=rcs
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.CMD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.CMD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.CMD/value=avr-gcc
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.ELF.CMD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.ELF.CMD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.ELF.CMD/value=avr-gcc
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.ELF.FLAGS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.ELF.FLAGS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.ELF.FLAGS/value=-Os -Wl,--gc-sections
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.FLAGS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.FLAGS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.C.FLAGS/value=-c -g -Os -w -ffunction-sections -fdata-sections -MMD
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.CPP.CMD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.CPP.CMD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.CPP.CMD/value=avr-g++
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.CPP.FLAGS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.CPP.FLAGS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.CPP.FLAGS/value=-c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.ELF2HEX.CMD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.ELF2HEX.CMD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.ELF2HEX.CMD/value=avr-objcopy
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CMD/value=${A.TOOLS.TEENSYLOADER.CMD}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.ELF2HEX.FLAGS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.ELF2HEX.FLAGS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.ELF2HEX.FLAGS/value=-O ihex -R .eeprom
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.LDFLAGS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.LDFLAGS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.LDFLAGS/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.OBJCOPY.CMD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.OBJCOPY.CMD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.OBJCOPY.CMD/value=avr-objcopy
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.OBJCOPY.EEP.FLAGS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.OBJCOPY.EEP.FLAGS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.OBJCOPY.EEP.FLAGS/value=-O ihex -j .eeprom --set-section-flags\=.eeprom\=alloc,load --no-change-warnings --change-section-lma .eeprom\=0
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.PATH/value=${A.RUNTIME.IDE.PATH}/hardware/tools/avr/bin/
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.S.FLAGS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.S.FLAGS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.S.FLAGS/value=-c -g -assembler-with-cpp
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SAM.PATH.LINUX/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SAM.PATH.LINUX/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SAM.PATH.LINUX/value=${A.RUNTIME.HARDWARE.PATH}/teensy/tools/linux/arm-none-eabi/bin/
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SAM.PATH.WINDOWS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SAM.PATH.WINDOWS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SAM.PATH.WINDOWS/value=${A.RUNTIME.HARDWARE.PATH}/teensy/tools/windows/arm-none-eabi/bin/
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SAM.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SAM.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SAM.PATH/value=${A.RUNTIME.HARDWARE.PATH}/teensy/tools/mac/arm-none-eabi/bin/
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SIZE.CMD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SIZE.CMD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.SIZE.CMD/value=avr-size
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.COMPILER.PATH/value=${A.RUNTIME.IDE.PATH}/
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CONFIG.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CONFIG.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CONFIG.PATH/value=${A.TOOLS.AVRDUDE.CONFIG.PATH}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.CONFIG.PATH/value=${A.TOOLS.TEENSYLOADER.CONFIG.PATH}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.DTS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.DTS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.DTS/value=3600
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.LOCAL/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.LOCAL/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.LOCAL/value=1431035468
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.UTC/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.UTC/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.UTC/value=1431028268
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.ZONE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.ZONE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.EXTRA.TIME.ZONE/value=3600
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.NAME/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.NAME/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.NAME/value=Teensy 3.1
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.PATH/value=${A.TOOLS.BOSSAC.PATH}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.PATH/value=${A.TOOLS.TEENSYLOADER.PATH}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN.1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN.1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN.1/value="${A.COMPILER.SAM.PATH}arm-none-eabi-ar" -r "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" ${A.OBJECT_FILE}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN.1/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.AR}" rcs "${A.BUILD.PATH}/${A.ARCHIVE_FILE}"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN.2/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN.2/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN.2/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN/value="${A.COMPILER.SAM.PATH}arm-none-eabi-ar" -r "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" ${A.OBJECT_FILE}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.AR.PATTERN/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.AR}" rcs "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" "${A.OBJECT_FILE}"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN.1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN.1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN.1/value="${A.COMPILER.SAM.PATH}arm-none-eabi-gcc" -Os -Wl,--gc-sections -mcpu\=${A.BUILD.MCU} -mthumb "-T${A.RUNTIME.HARDWARE.PATH}/${A.BUILD.LDSCRIPT}" -o "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN.1/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.GCC}" ${A.BUILD.FLAGS.OPTIMIZE} ${A.BUILD.FLAGS.LD} --specs\=nano.specs ${A.BUILD.FLAGS.CPU} -o "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN.2/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN.2/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN.2/value=\ -L"${A.BUILD.PATH}" -lm
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN.2/value=\ "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" "-L${A.BUILD.PATH}" ${A.BUILD.FLAGS.LIBS}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN/value="${A.COMPILER.SAM.PATH}arm-none-eabi-gcc" -Os -Wl,--gc-sections -mcpu\=${A.BUILD.MCU} -mthumb "-T${A.RUNTIME.HARDWARE.PATH}/${A.BUILD.LDSCRIPT}" -o "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" ${A.OBJECT_FILES} -L"${A.BUILD.PATH}" -lm
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.COMBINE.PATTERN/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.GCC}" ${A.BUILD.FLAGS.OPTIMIZE} ${A.BUILD.FLAGS.LD} --specs\=nano.specs ${A.BUILD.FLAGS.CPU} -o "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" ${A.OBJECT_FILES} "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" "-L${A.BUILD.PATH}" ${A.BUILD.FLAGS.LIBS}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN.1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN.1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN.1/value="${A.COMPILER.SAM.PATH}arm-none-eabi-gcc" -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -DTIME_T\=1365449461 ${A.BUILD.DEFINE0} ${A.BUILD.DEFINE1} -MMD -D${A.SOFTWARE}\=${A.RUNTIME.IDE.VERSION} ${A.BUILD.EXTRA_FLAGS} -mthumb -D__MK20DX256__ ${A.INCLUDES}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN.1/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.GCC}" -c ${A.BUILD.FLAGS.OPTIMIZE} ${A.BUILD.FLAGS.COMMON} ${A.BUILD.FLAGS.C} ${A.BUILD.FLAGS.CPU} ${A.BUILD.FLAGS.DEFS} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DF_CPU\=${A.BUILD.FCPU} -DARDUINO_ARCH_AVR -D${A.BUILD.USBTYPE} -DLAYOUT_${A.BUILD.KEYLAYOUT} ${A.INCLUDES}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN.2/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN.2/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN.2/value=\ -o
|
||||
@ -202,10 +157,10 @@ environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN.3/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN/value="${A.COMPILER.SAM.PATH}arm-none-eabi-gcc" -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -DTIME_T\=1365449461 ${A.BUILD.DEFINE0} ${A.BUILD.DEFINE1} -MMD -D${A.SOFTWARE}\=${A.RUNTIME.IDE.VERSION} ${A.BUILD.EXTRA_FLAGS} -mthumb -D__MK20DX256__ ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.C.O.PATTERN/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.GCC}" -c ${A.BUILD.FLAGS.OPTIMIZE} ${A.BUILD.FLAGS.COMMON} ${A.BUILD.FLAGS.C} ${A.BUILD.FLAGS.CPU} ${A.BUILD.FLAGS.DEFS} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DF_CPU\=${A.BUILD.FCPU} -DARDUINO_ARCH_AVR -D${A.BUILD.USBTYPE} -DLAYOUT_${A.BUILD.KEYLAYOUT} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN.1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN.1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN.1/value="${A.COMPILER.SAM.PATH}arm-none-eabi-g++" -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib -fno-rtti -fno-exceptions -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} ${A.BUILD.DEFINE0} ${A.BUILD.DEFINE1} -MMD -D${A.SOFTWARE}\=${A.RUNTIME.IDE.VERSION} ${A.BUILD.EXTRA_FLAGS} -mthumb -D__MK20DX256__ -felide-constructors -std\=gnu++0x ${A.INCLUDES}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN.1/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.G++}" -c ${A.BUILD.FLAGS.OPTIMIZE} ${A.BUILD.FLAGS.COMMON} ${A.BUILD.FLAGS.CPP} ${A.BUILD.FLAGS.CPU} ${A.BUILD.FLAGS.DEFS} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DF_CPU\=${A.BUILD.FCPU} -DARDUINO_ARCH_AVR -D${A.BUILD.USBTYPE} -DLAYOUT_${A.BUILD.KEYLAYOUT} ${A.INCLUDES}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN.2/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN.2/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN.2/value=\ -o
|
||||
@ -214,28 +169,49 @@ environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN.3/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN/value="${A.COMPILER.SAM.PATH}arm-none-eabi-g++" -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib -fno-rtti -fno-exceptions -mcpu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} ${A.BUILD.DEFINE0} ${A.BUILD.DEFINE1} -MMD -D${A.SOFTWARE}\=${A.RUNTIME.IDE.VERSION} ${A.BUILD.EXTRA_FLAGS} -mthumb -D__MK20DX256__ -felide-constructors -std\=gnu++0x ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.CPP.O.PATTERN/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.G++}" -c ${A.BUILD.FLAGS.OPTIMIZE} ${A.BUILD.FLAGS.COMMON} ${A.BUILD.FLAGS.CPP} ${A.BUILD.FLAGS.CPU} ${A.BUILD.FLAGS.DEFS} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DF_CPU\=${A.BUILD.FCPU} -DARDUINO_ARCH_AVR -D${A.BUILD.USBTYPE} -DLAYOUT_${A.BUILD.KEYLAYOUT} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.ELFPATCH.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.ELFPATCH.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.ELFPATCH.PATTERN/value="${A.COMPILER.PATH}/hardware/tools/${A.BUILD.ELFPATCH}" -mmcu\=${A.BUILD.MCU} "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" "${A.SKETCH_PATH}/disk"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.EEP.PATTERN.1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.EEP.PATTERN.1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.EEP.PATTERN.1/value="${A.COMPILER.SAM.PATH}arm-none-eabi-objcopy" -O ihex -j .eeprom --set-section-flags\=.eeprom\=alloc,load --no-change-warnings --change-section-lma .eeprom\=0 "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.eep"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.EEP.PATTERN.1/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.OBJCOPY}" ${A.COMPILER.OBJCOPY.EEP.FLAGS} "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.eep"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.EEP.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.EEP.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.EEP.PATTERN/value="${A.COMPILER.SAM.PATH}arm-none-eabi-objcopy" -O ihex -j .eeprom --set-section-flags\=.eeprom\=alloc,load --no-change-warnings --change-section-lma .eeprom\=0 "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.eep"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.EEP.PATTERN/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.OBJCOPY}" ${A.COMPILER.OBJCOPY.EEP.FLAGS} "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.eep"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.HEX.PATTERN.1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.HEX.PATTERN.1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.HEX.PATTERN.1/value="${A.COMPILER.SAM.PATH}arm-none-eabi-objcopy" -O ihex -R .eeprom "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.hex"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.HEX.PATTERN.1/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.OBJCOPY}" ${A.COMPILER.ELF2HEX.FLAGS} "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.hex"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.HEX.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.HEX.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.HEX.PATTERN/value="${A.COMPILER.SAM.PATH}arm-none-eabi-objcopy" -O ihex -R .eeprom "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.hex"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.OBJCOPY.HEX.PATTERN/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.OBJCOPY}" ${A.COMPILER.ELF2HEX.FLAGS} "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.hex"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN.1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN.1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN.1/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.GCC}" -c ${A.BUILD.FLAGS.OPTIMIZE} ${A.BUILD.FLAGS.COMMON} ${A.BUILD.FLAGS.S} ${A.BUILD.FLAGS.CPU} ${A.BUILD.FLAGS.DEFS} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DF_CPU\=${A.BUILD.FCPU} -DARDUINO_ARCH_AVR -D${A.BUILD.USBTYPE} -DLAYOUT_${A.BUILD.KEYLAYOUT} ${A.INCLUDES}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN.2/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN.2/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN.2/value=\ -o
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN.3/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN.3/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN.3/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.S.O.PATTERN/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.GCC}" -c ${A.BUILD.FLAGS.OPTIMIZE} ${A.BUILD.FLAGS.COMMON} ${A.BUILD.FLAGS.S} ${A.BUILD.FLAGS.CPU} ${A.BUILD.FLAGS.DEFS} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DF_CPU\=${A.BUILD.FCPU} -DARDUINO_ARCH_AVR -D${A.BUILD.USBTYPE} -DLAYOUT_${A.BUILD.KEYLAYOUT} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.OBJECT_FILE}"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.PATTERN.1/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.PATTERN.1/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.PATTERN.1/value="${A.COMPILER.SAM.PATH}arm-none-eabi-size" -A "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.PATTERN.1/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.SIZE}" -A "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.PATTERN/value="${A.COMPILER.SAM.PATH}arm-none-eabi-size" -A "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.PATTERN/value="${A.COMPILER.PATH}${A.BUILD.TOOLCHAIN}${A.BUILD.COMMAND.SIZE}" -A "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf"
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.REGEX.DATA/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.REGEX.DATA/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.REGEX.DATA/value=^(?\:\\.usbdescriptortable|\\.dmabuffers|\\.usbbuffers|\\.data|\\.bss|\\.noinit)\\s+([0-9]+).*
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.REGEX.EEPROM/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.REGEX.EEPROM/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.REGEX.EEPROM/value=^(?\:\\.eeprom)\\s+([0-9]+).*
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.REGEX/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.REGEX/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.REGEX/value=Total\\s+([0-9]+).*
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RECIPE.SIZE.REGEX/value=^(?\:\\.text|\\.data|\\.bootloader)\\s+([0-9]+).*
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.HARDWARE.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.HARDWARE.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.HARDWARE.PATH/value=/Applications/Arduino.app/Contents/Resources/Java/hardware
|
||||
@ -244,79 +220,58 @@ environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIM
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.IDE.PATH/value=/Applications/Arduino.app/Contents/Resources/Java
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.IDE.VERSION/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.IDE.VERSION/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.IDE.VERSION/value=152
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.IDE.VERSION/value=161
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.PLATFORM.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.PLATFORM.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.RUNTIME.PLATFORM.PATH/value=/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/avr
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.SERIAL.RESTART_CMD/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.SERIAL.RESTART_CMD/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.SERIAL.RESTART_CMD/value=true
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.SERIAL.SAFE_BAUD_RATES_ONLY/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.SERIAL.SAFE_BAUD_RATES_ONLY/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.SERIAL.SAFE_BAUD_RATES_ONLY/value=true
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.SERIAL.RESTART_CMD/value=false
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.SOFTWARE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.SOFTWARE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.SOFTWARE/value=ARDUINO
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CMD.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CMD.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CMD.PATH/value=${A.TOOLS.TEENSY_REBOOT.CONFIG.PATH}/
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CONFIG.PATH.LINUX/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CONFIG.PATH.LINUX/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CONFIG.PATH.LINUX/value=${A.RUNTIME.HARDWARE.PATH}/teensy/tools/linux
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CONFIG.PATH.WINDOWS/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CONFIG.PATH.WINDOWS/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CONFIG.PATH.WINDOWS/value=${A.RUNTIME.HARDWARE.PATH}/teensy/tools/windows
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CONFIG.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CONFIG.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.CONFIG.PATH/value=${A.RUNTIME.HARDWARE.PATH}/teensy/tools/mac
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.NAME/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.NAME/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.NAME/value=Teensy upload
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP1.NAME/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP1.NAME/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP1.NAME/value=Teensy post compile
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP1.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP1.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP1.PATTERN/value=${A.TOOLS.TEENSY_REBOOT.CMD.PATH}teensy_post_compile -path\=${A.BUILD.PATH} -file\=${A.BUILD.PROJECT_NAME} -tools\=${A.TOOLS.TEENSY_REBOOT.CONFIG.PATH} -board\=${A.NAME}
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP2.NAME/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP2.NAME/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP2.NAME/value=Teensy reboot
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP2.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP2.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.STEP2.PATTERN/value=${A.TOOLS.TEENSY_REBOOT.CMD.PATH}teensy_reboot -v
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.UPLOAD.PARAMS.QUIET/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.UPLOAD.PARAMS.QUIET/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.UPLOAD.PARAMS.QUIET/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.UPLOAD.PARAMS.VERBOSE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.UPLOAD.PARAMS.VERBOSE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSY_REBOOT.UPLOAD.PARAMS.VERBOSE/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.DISABLE_FLUSHING/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.DISABLE_FLUSHING/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.DISABLE_FLUSHING/value=true
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.MAXIMUM_RAM_SIZE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.MAXIMUM_RAM_SIZE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.MAXIMUM_RAM_SIZE/value=65536
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.CMD.PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.CMD.PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.CMD.PATH/value=${A.RUNTIME.IDE.PATH}/hardware/tools/teensy_post_compile
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.UPLOAD.PARAMS.QUIET/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.UPLOAD.PARAMS.QUIET/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.UPLOAD.PARAMS.QUIET/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.UPLOAD.PARAMS.VERBOSE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.UPLOAD.PARAMS.VERBOSE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.UPLOAD.PARAMS.VERBOSE/value=-verbose
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.UPLOAD.PATTERN/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.UPLOAD.PATTERN/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.TOOLS.TEENSYLOADER.UPLOAD.PATTERN/value="${A.CMD.PATH}" "-file\=${A.BUILD.PROJECT_NAME}" "-path\=${A.BUILD.PATH}" "-tools\=${A.RUNTIME.IDE.PATH}/hardware/tools" "-board\=${A.BUILD.BOARD}" -reboot
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.MAXIMUM_DATA_SIZE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.MAXIMUM_DATA_SIZE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.MAXIMUM_DATA_SIZE/value=65536
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.MAXIMUM_SIZE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.MAXIMUM_SIZE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.MAXIMUM_SIZE/value=262144
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.PROTOCOL/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.PROTOCOL/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.PROTOCOL/value=halfkay
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.SPEED/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.SPEED/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.SPEED/value=12000000
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.TOOL/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.TOOL/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.TOOL/value=teensy_reboot
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.UPLOAD.TOOL/value=teensyloader
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.VERSION/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.VERSION/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/A.VERSION/value=1.6.0
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.BOARDS_FILE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.BOARDS_FILE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.BOARDS_FILE/value=/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/all/boards.txt
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.BOARDS_FILE/value=/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/avr/boards.txt
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.BOARD_NAME/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.BOARD_NAME/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.BOARD_NAME/value=Teensy 3.1
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.COM_PORT/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.COM_PORT/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.COM_PORT/value=/dev
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.COM_PROGMR/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.COM_PROGMR/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.COM_PROGMR/value=Default
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.CPU\ Speed/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.CPU\ Speed/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.CPU\ Speed/value=24 MHz
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.CPU\ Speed/value=72 MHz
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.EXTRA.C.COMPILE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.EXTRA.C.COMPILE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.EXTRA.C.COMPILE/value=
|
||||
@ -328,10 +283,10 @@ environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.E
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.EXTRA.CPP.COMPILE/value=
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.Keyboard\ Layout/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.Keyboard\ Layout/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.Keyboard\ Layout/value=US English
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.Keyboard\ Layout/value=German (Mac)
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.PLATFORM_FILE/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.PLATFORM_FILE/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.PLATFORM_FILE/value=/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/all/platform.txt
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.PLATFORM_FILE/value=/Applications/Arduino.app/Contents/Resources/Java/hardware/teensy/avr/platform.txt
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.Processor/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.Processor/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.Processor/value=
|
||||
@ -350,6 +305,9 @@ environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.T
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.USB\ Type/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.USB\ Type/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.USB\ Type/value=Serial
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.WARNING_LEVEL/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.WARNING_LEVEL/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/JANTJE.WARNING_LEVEL/value=\ -w
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/PATH/delimiter=\:
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/PATH/operation=replace
|
||||
environment/project/it.baeyens.arduino.core.toolChain.release.400069008/PATH/value=${A.COMPILER.PATH}${PathDelimiter}${A.BUILD.GENERIC.PATH}${PathDelimiter}${PATH}
|
||||
|
50
EEPROM/EEPROM.cpp
Normal file
50
EEPROM/EEPROM.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
EEPROM.cpp - EEPROM library
|
||||
Copyright (c) 2006 David A. Mellis. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <avr/eeprom.h>
|
||||
#include "Arduino.h"
|
||||
#include "EEPROM.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Constructors
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* User API
|
||||
******************************************************************************/
|
||||
|
||||
uint8_t EEPROMClass::read(int address)
|
||||
{
|
||||
return eeprom_read_byte((unsigned char *) address);
|
||||
}
|
||||
|
||||
void EEPROMClass::write(int address, uint8_t value)
|
||||
{
|
||||
eeprom_write_byte((unsigned char *) address, value);
|
||||
}
|
||||
|
||||
EEPROMClass EEPROM;
|
42
EEPROM/EEPROM.h
Normal file
42
EEPROM/EEPROM.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
EEPROM.h - EEPROM library
|
||||
Copyright (c) 2006 David A. Mellis. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef EEPROM_h
|
||||
#define EEPROM_h
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__)
|
||||
#include "avr_functions.h"
|
||||
#endif
|
||||
|
||||
class EEPROMClass
|
||||
{
|
||||
public:
|
||||
#if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__)
|
||||
EEPROMClass() { eeprom_initialize(); }
|
||||
#endif
|
||||
uint8_t read(int);
|
||||
void write(int, uint8_t);
|
||||
};
|
||||
|
||||
extern EEPROMClass EEPROM;
|
||||
|
||||
#endif
|
||||
|
480
Ethernet/Dhcp.cpp
Normal file
480
Ethernet/Dhcp.cpp
Normal file
@ -0,0 +1,480 @@
|
||||
// DHCP Library v0.3 - April 25, 2009
|
||||
// Author: Jordan Terrell - blog.jordanterrell.com
|
||||
|
||||
#include "w5100.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "Dhcp.h"
|
||||
#include "Arduino.h"
|
||||
#include "util.h"
|
||||
|
||||
int DhcpClass::beginWithDHCP(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout)
|
||||
{
|
||||
_dhcpLeaseTime=0;
|
||||
_dhcpT1=0;
|
||||
_dhcpT2=0;
|
||||
_lastCheck=0;
|
||||
_timeout = timeout;
|
||||
_responseTimeout = responseTimeout;
|
||||
|
||||
// zero out _dhcpMacAddr
|
||||
memset(_dhcpMacAddr, 0, 6);
|
||||
reset_DHCP_lease();
|
||||
|
||||
memcpy((void*)_dhcpMacAddr, (void*)mac, 6);
|
||||
_dhcp_state = STATE_DHCP_START;
|
||||
return request_DHCP_lease();
|
||||
}
|
||||
|
||||
void DhcpClass::reset_DHCP_lease(){
|
||||
// zero out _dhcpSubnetMask, _dhcpGatewayIp, _dhcpLocalIp, _dhcpDhcpServerIp, _dhcpDnsServerIp
|
||||
memset(_dhcpLocalIp, 0, 20);
|
||||
}
|
||||
|
||||
//return:0 on error, 1 if request is sent and response is received
|
||||
int DhcpClass::request_DHCP_lease(){
|
||||
|
||||
uint8_t messageType = 0;
|
||||
|
||||
|
||||
|
||||
// Pick an initial transaction ID
|
||||
_dhcpTransactionId = random(1UL, 2000UL);
|
||||
_dhcpInitialTransactionId = _dhcpTransactionId;
|
||||
|
||||
_dhcpUdpSocket.stop();
|
||||
if (_dhcpUdpSocket.begin(DHCP_CLIENT_PORT) == 0)
|
||||
{
|
||||
// Couldn't get a socket
|
||||
return 0;
|
||||
}
|
||||
|
||||
presend_DHCP();
|
||||
|
||||
int result = 0;
|
||||
|
||||
unsigned long startTime = millis();
|
||||
|
||||
while(_dhcp_state != STATE_DHCP_LEASED)
|
||||
{
|
||||
if(_dhcp_state == STATE_DHCP_START)
|
||||
{
|
||||
_dhcpTransactionId++;
|
||||
|
||||
send_DHCP_MESSAGE(DHCP_DISCOVER, ((millis() - startTime) / 1000));
|
||||
_dhcp_state = STATE_DHCP_DISCOVER;
|
||||
}
|
||||
else if(_dhcp_state == STATE_DHCP_REREQUEST){
|
||||
_dhcpTransactionId++;
|
||||
send_DHCP_MESSAGE(DHCP_REQUEST, ((millis() - startTime)/1000));
|
||||
_dhcp_state = STATE_DHCP_REQUEST;
|
||||
}
|
||||
else if(_dhcp_state == STATE_DHCP_DISCOVER)
|
||||
{
|
||||
uint32_t respId;
|
||||
messageType = parseDHCPResponse(_responseTimeout, respId);
|
||||
if(messageType == DHCP_OFFER)
|
||||
{
|
||||
// We'll use the transaction ID that the offer came with,
|
||||
// rather than the one we were up to
|
||||
_dhcpTransactionId = respId;
|
||||
send_DHCP_MESSAGE(DHCP_REQUEST, ((millis() - startTime) / 1000));
|
||||
_dhcp_state = STATE_DHCP_REQUEST;
|
||||
}
|
||||
}
|
||||
else if(_dhcp_state == STATE_DHCP_REQUEST)
|
||||
{
|
||||
uint32_t respId;
|
||||
messageType = parseDHCPResponse(_responseTimeout, respId);
|
||||
if(messageType == DHCP_ACK)
|
||||
{
|
||||
_dhcp_state = STATE_DHCP_LEASED;
|
||||
result = 1;
|
||||
//use default lease time if we didn't get it
|
||||
if(_dhcpLeaseTime == 0){
|
||||
_dhcpLeaseTime = DEFAULT_LEASE;
|
||||
}
|
||||
//calculate T1 & T2 if we didn't get it
|
||||
if(_dhcpT1 == 0){
|
||||
//T1 should be 50% of _dhcpLeaseTime
|
||||
_dhcpT1 = _dhcpLeaseTime >> 1;
|
||||
}
|
||||
if(_dhcpT2 == 0){
|
||||
//T2 should be 87.5% (7/8ths) of _dhcpLeaseTime
|
||||
_dhcpT2 = _dhcpT1 << 1;
|
||||
}
|
||||
_renewInSec = _dhcpT1;
|
||||
_rebindInSec = _dhcpT2;
|
||||
}
|
||||
else if(messageType == DHCP_NAK)
|
||||
_dhcp_state = STATE_DHCP_START;
|
||||
}
|
||||
|
||||
if(messageType == 255)
|
||||
{
|
||||
messageType = 0;
|
||||
_dhcp_state = STATE_DHCP_START;
|
||||
}
|
||||
|
||||
if(result != 1 && ((millis() - startTime) > _timeout))
|
||||
break;
|
||||
}
|
||||
|
||||
// We're done with the socket now
|
||||
_dhcpUdpSocket.stop();
|
||||
_dhcpTransactionId++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void DhcpClass::presend_DHCP()
|
||||
{
|
||||
}
|
||||
|
||||
void DhcpClass::send_DHCP_MESSAGE(uint8_t messageType, uint16_t secondsElapsed)
|
||||
{
|
||||
uint8_t buffer[32];
|
||||
memset(buffer, 0, 32);
|
||||
IPAddress dest_addr( 255, 255, 255, 255 ); // Broadcast address
|
||||
|
||||
if (-1 == _dhcpUdpSocket.beginPacket(dest_addr, DHCP_SERVER_PORT))
|
||||
{
|
||||
// FIXME Need to return errors
|
||||
return;
|
||||
}
|
||||
|
||||
buffer[0] = DHCP_BOOTREQUEST; // op
|
||||
buffer[1] = DHCP_HTYPE10MB; // htype
|
||||
buffer[2] = DHCP_HLENETHERNET; // hlen
|
||||
buffer[3] = DHCP_HOPS; // hops
|
||||
|
||||
// xid
|
||||
unsigned long xid = htonl(_dhcpTransactionId);
|
||||
memcpy(buffer + 4, &(xid), 4);
|
||||
|
||||
// 8, 9 - seconds elapsed
|
||||
buffer[8] = ((secondsElapsed & 0xff00) >> 8);
|
||||
buffer[9] = (secondsElapsed & 0x00ff);
|
||||
|
||||
// flags
|
||||
unsigned short flags = htons(DHCP_FLAGSBROADCAST);
|
||||
memcpy(buffer + 10, &(flags), 2);
|
||||
|
||||
// ciaddr: already zeroed
|
||||
// yiaddr: already zeroed
|
||||
// siaddr: already zeroed
|
||||
// giaddr: already zeroed
|
||||
|
||||
//put data in W5100 transmit buffer
|
||||
_dhcpUdpSocket.write(buffer, 28);
|
||||
|
||||
memset(buffer, 0, 32); // clear local buffer
|
||||
|
||||
memcpy(buffer, _dhcpMacAddr, 6); // chaddr
|
||||
|
||||
//put data in W5100 transmit buffer
|
||||
_dhcpUdpSocket.write(buffer, 16);
|
||||
|
||||
memset(buffer, 0, 32); // clear local buffer
|
||||
|
||||
// leave zeroed out for sname && file
|
||||
// put in W5100 transmit buffer x 6 (192 bytes)
|
||||
|
||||
for(int i = 0; i < 6; i++) {
|
||||
_dhcpUdpSocket.write(buffer, 32);
|
||||
}
|
||||
|
||||
// OPT - Magic Cookie
|
||||
buffer[0] = (uint8_t)((MAGIC_COOKIE >> 24)& 0xFF);
|
||||
buffer[1] = (uint8_t)((MAGIC_COOKIE >> 16)& 0xFF);
|
||||
buffer[2] = (uint8_t)((MAGIC_COOKIE >> 8)& 0xFF);
|
||||
buffer[3] = (uint8_t)(MAGIC_COOKIE& 0xFF);
|
||||
|
||||
// OPT - message type
|
||||
buffer[4] = dhcpMessageType;
|
||||
buffer[5] = 0x01;
|
||||
buffer[6] = messageType; //DHCP_REQUEST;
|
||||
|
||||
// OPT - client identifier
|
||||
buffer[7] = dhcpClientIdentifier;
|
||||
buffer[8] = 0x07;
|
||||
buffer[9] = 0x01;
|
||||
memcpy(buffer + 10, _dhcpMacAddr, 6);
|
||||
|
||||
// OPT - host name
|
||||
buffer[16] = hostName;
|
||||
buffer[17] = strlen(HOST_NAME) + 6; // length of hostname + last 3 bytes of mac address
|
||||
strcpy((char*)&(buffer[18]), HOST_NAME);
|
||||
|
||||
printByte((char*)&(buffer[24]), _dhcpMacAddr[3]);
|
||||
printByte((char*)&(buffer[26]), _dhcpMacAddr[4]);
|
||||
printByte((char*)&(buffer[28]), _dhcpMacAddr[5]);
|
||||
|
||||
//put data in W5100 transmit buffer
|
||||
_dhcpUdpSocket.write(buffer, 30);
|
||||
|
||||
if(messageType == DHCP_REQUEST)
|
||||
{
|
||||
buffer[0] = dhcpRequestedIPaddr;
|
||||
buffer[1] = 0x04;
|
||||
buffer[2] = _dhcpLocalIp[0];
|
||||
buffer[3] = _dhcpLocalIp[1];
|
||||
buffer[4] = _dhcpLocalIp[2];
|
||||
buffer[5] = _dhcpLocalIp[3];
|
||||
|
||||
buffer[6] = dhcpServerIdentifier;
|
||||
buffer[7] = 0x04;
|
||||
buffer[8] = _dhcpDhcpServerIp[0];
|
||||
buffer[9] = _dhcpDhcpServerIp[1];
|
||||
buffer[10] = _dhcpDhcpServerIp[2];
|
||||
buffer[11] = _dhcpDhcpServerIp[3];
|
||||
|
||||
//put data in W5100 transmit buffer
|
||||
_dhcpUdpSocket.write(buffer, 12);
|
||||
}
|
||||
|
||||
buffer[0] = dhcpParamRequest;
|
||||
buffer[1] = 0x06;
|
||||
buffer[2] = subnetMask;
|
||||
buffer[3] = routersOnSubnet;
|
||||
buffer[4] = dns;
|
||||
buffer[5] = domainName;
|
||||
buffer[6] = dhcpT1value;
|
||||
buffer[7] = dhcpT2value;
|
||||
buffer[8] = endOption;
|
||||
|
||||
//put data in W5100 transmit buffer
|
||||
_dhcpUdpSocket.write(buffer, 9);
|
||||
|
||||
_dhcpUdpSocket.endPacket();
|
||||
}
|
||||
|
||||
uint8_t DhcpClass::parseDHCPResponse(unsigned long responseTimeout, uint32_t& transactionId)
|
||||
{
|
||||
uint8_t type = 0;
|
||||
uint8_t opt_len = 0;
|
||||
|
||||
unsigned long startTime = millis();
|
||||
|
||||
while(_dhcpUdpSocket.parsePacket() <= 0)
|
||||
{
|
||||
if((millis() - startTime) > responseTimeout)
|
||||
{
|
||||
return 255;
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
// start reading in the packet
|
||||
RIP_MSG_FIXED fixedMsg;
|
||||
_dhcpUdpSocket.read((uint8_t*)&fixedMsg, sizeof(RIP_MSG_FIXED));
|
||||
|
||||
if(fixedMsg.op == DHCP_BOOTREPLY && _dhcpUdpSocket.remotePort() == DHCP_SERVER_PORT)
|
||||
{
|
||||
transactionId = ntohl(fixedMsg.xid);
|
||||
if(memcmp(fixedMsg.chaddr, _dhcpMacAddr, 6) != 0 || (transactionId < _dhcpInitialTransactionId) || (transactionId > _dhcpTransactionId))
|
||||
{
|
||||
// Need to read the rest of the packet here regardless
|
||||
_dhcpUdpSocket.flush();
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(_dhcpLocalIp, fixedMsg.yiaddr, 4);
|
||||
|
||||
// Skip to the option part
|
||||
// Doing this a byte at a time so we don't have to put a big buffer
|
||||
// on the stack (as we don't have lots of memory lying around)
|
||||
for (int i =0; i < (240 - (int)sizeof(RIP_MSG_FIXED)); i++)
|
||||
{
|
||||
_dhcpUdpSocket.read(); // we don't care about the returned byte
|
||||
}
|
||||
|
||||
while (_dhcpUdpSocket.available() > 0)
|
||||
{
|
||||
switch (_dhcpUdpSocket.read())
|
||||
{
|
||||
case endOption :
|
||||
break;
|
||||
|
||||
case padOption :
|
||||
break;
|
||||
|
||||
case dhcpMessageType :
|
||||
opt_len = _dhcpUdpSocket.read();
|
||||
type = _dhcpUdpSocket.read();
|
||||
break;
|
||||
|
||||
case subnetMask :
|
||||
opt_len = _dhcpUdpSocket.read();
|
||||
_dhcpUdpSocket.read(_dhcpSubnetMask, 4);
|
||||
break;
|
||||
|
||||
case routersOnSubnet :
|
||||
opt_len = _dhcpUdpSocket.read();
|
||||
_dhcpUdpSocket.read(_dhcpGatewayIp, 4);
|
||||
for (int i = 0; i < opt_len-4; i++)
|
||||
{
|
||||
_dhcpUdpSocket.read();
|
||||
}
|
||||
break;
|
||||
|
||||
case dns :
|
||||
opt_len = _dhcpUdpSocket.read();
|
||||
_dhcpUdpSocket.read(_dhcpDnsServerIp, 4);
|
||||
for (int i = 0; i < opt_len-4; i++)
|
||||
{
|
||||
_dhcpUdpSocket.read();
|
||||
}
|
||||
break;
|
||||
|
||||
case dhcpServerIdentifier :
|
||||
opt_len = _dhcpUdpSocket.read();
|
||||
if( *((uint32_t*)_dhcpDhcpServerIp) == 0 ||
|
||||
IPAddress(_dhcpDhcpServerIp) == _dhcpUdpSocket.remoteIP() )
|
||||
{
|
||||
_dhcpUdpSocket.read(_dhcpDhcpServerIp, sizeof(_dhcpDhcpServerIp));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skip over the rest of this option
|
||||
while (opt_len--)
|
||||
{
|
||||
_dhcpUdpSocket.read();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case dhcpT1value :
|
||||
opt_len = _dhcpUdpSocket.read();
|
||||
_dhcpUdpSocket.read((uint8_t*)&_dhcpT1, sizeof(_dhcpT1));
|
||||
_dhcpT1 = ntohl(_dhcpT1);
|
||||
break;
|
||||
|
||||
case dhcpT2value :
|
||||
opt_len = _dhcpUdpSocket.read();
|
||||
_dhcpUdpSocket.read((uint8_t*)&_dhcpT2, sizeof(_dhcpT2));
|
||||
_dhcpT2 = ntohl(_dhcpT2);
|
||||
break;
|
||||
|
||||
case dhcpIPaddrLeaseTime :
|
||||
opt_len = _dhcpUdpSocket.read();
|
||||
_dhcpUdpSocket.read((uint8_t*)&_dhcpLeaseTime, sizeof(_dhcpLeaseTime));
|
||||
_dhcpLeaseTime = ntohl(_dhcpLeaseTime);
|
||||
_renewInSec = _dhcpLeaseTime;
|
||||
break;
|
||||
|
||||
default :
|
||||
opt_len = _dhcpUdpSocket.read();
|
||||
// Skip over the rest of this option
|
||||
while (opt_len--)
|
||||
{
|
||||
_dhcpUdpSocket.read();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Need to skip to end of the packet regardless here
|
||||
_dhcpUdpSocket.flush();
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
returns:
|
||||
0/DHCP_CHECK_NONE: nothing happened
|
||||
1/DHCP_CHECK_RENEW_FAIL: renew failed
|
||||
2/DHCP_CHECK_RENEW_OK: renew success
|
||||
3/DHCP_CHECK_REBIND_FAIL: rebind fail
|
||||
4/DHCP_CHECK_REBIND_OK: rebind success
|
||||
*/
|
||||
int DhcpClass::checkLease(){
|
||||
//this uses a signed / unsigned trick to deal with millis overflow
|
||||
unsigned long now = millis();
|
||||
signed long snow = (long)now;
|
||||
int rc=DHCP_CHECK_NONE;
|
||||
if (_lastCheck != 0){
|
||||
signed long factor;
|
||||
//calc how many ms past the timeout we are
|
||||
factor = snow - (long)_secTimeout;
|
||||
//if on or passed the timeout, reduce the counters
|
||||
if ( factor >= 0 ){
|
||||
//next timeout should be now plus 1000 ms minus parts of second in factor
|
||||
_secTimeout = snow + 1000 - factor % 1000;
|
||||
//how many seconds late are we, minimum 1
|
||||
factor = factor / 1000 +1;
|
||||
|
||||
//reduce the counters by that mouch
|
||||
//if we can assume that the cycle time (factor) is fairly constant
|
||||
//and if the remainder is less than cycle time * 2
|
||||
//do it early instead of late
|
||||
if(_renewInSec < factor*2 )
|
||||
_renewInSec = 0;
|
||||
else
|
||||
_renewInSec -= factor;
|
||||
|
||||
if(_rebindInSec < factor*2 )
|
||||
_rebindInSec = 0;
|
||||
else
|
||||
_rebindInSec -= factor;
|
||||
}
|
||||
|
||||
//if we have a lease but should renew, do it
|
||||
if (_dhcp_state == STATE_DHCP_LEASED && _renewInSec <=0){
|
||||
_dhcp_state = STATE_DHCP_REREQUEST;
|
||||
rc = 1 + request_DHCP_lease();
|
||||
}
|
||||
|
||||
//if we have a lease or is renewing but should bind, do it
|
||||
if( (_dhcp_state == STATE_DHCP_LEASED || _dhcp_state == STATE_DHCP_START) && _rebindInSec <=0){
|
||||
//this should basically restart completely
|
||||
_dhcp_state = STATE_DHCP_START;
|
||||
reset_DHCP_lease();
|
||||
rc = 3 + request_DHCP_lease();
|
||||
}
|
||||
}
|
||||
else{
|
||||
_secTimeout = snow + 1000;
|
||||
}
|
||||
|
||||
_lastCheck = now;
|
||||
return rc;
|
||||
}
|
||||
|
||||
IPAddress DhcpClass::getLocalIp()
|
||||
{
|
||||
return IPAddress(_dhcpLocalIp);
|
||||
}
|
||||
|
||||
IPAddress DhcpClass::getSubnetMask()
|
||||
{
|
||||
return IPAddress(_dhcpSubnetMask);
|
||||
}
|
||||
|
||||
IPAddress DhcpClass::getGatewayIp()
|
||||
{
|
||||
return IPAddress(_dhcpGatewayIp);
|
||||
}
|
||||
|
||||
IPAddress DhcpClass::getDhcpServerIp()
|
||||
{
|
||||
return IPAddress(_dhcpDhcpServerIp);
|
||||
}
|
||||
|
||||
IPAddress DhcpClass::getDnsServerIp()
|
||||
{
|
||||
return IPAddress(_dhcpDnsServerIp);
|
||||
}
|
||||
|
||||
void DhcpClass::printByte(char * buf, uint8_t n ) {
|
||||
char *str = &buf[1];
|
||||
buf[0]='0';
|
||||
do {
|
||||
unsigned long m = n;
|
||||
n /= 16;
|
||||
char c = m - 16 * n;
|
||||
*str-- = c < 10 ? c + '0' : c + 'A' - 10;
|
||||
} while(n);
|
||||
}
|
186
Ethernet/Dhcp.h
Normal file
186
Ethernet/Dhcp.h
Normal file
@ -0,0 +1,186 @@
|
||||
// DHCP Library v0.3 - April 25, 2009
|
||||
// Author: Jordan Terrell - blog.jordanterrell.com
|
||||
|
||||
#ifndef Dhcp_h
|
||||
#define Dhcp_h
|
||||
|
||||
#include "EthernetUdp.h"
|
||||
|
||||
/* DHCP state machine. */
|
||||
#define STATE_DHCP_START 0
|
||||
#define STATE_DHCP_DISCOVER 1
|
||||
#define STATE_DHCP_REQUEST 2
|
||||
#define STATE_DHCP_LEASED 3
|
||||
#define STATE_DHCP_REREQUEST 4
|
||||
#define STATE_DHCP_RELEASE 5
|
||||
|
||||
#define DHCP_FLAGSBROADCAST 0x8000
|
||||
|
||||
/* UDP port numbers for DHCP */
|
||||
#define DHCP_SERVER_PORT 67 /* from server to client */
|
||||
#define DHCP_CLIENT_PORT 68 /* from client to server */
|
||||
|
||||
/* DHCP message OP code */
|
||||
#define DHCP_BOOTREQUEST 1
|
||||
#define DHCP_BOOTREPLY 2
|
||||
|
||||
/* DHCP message type */
|
||||
#define DHCP_DISCOVER 1
|
||||
#define DHCP_OFFER 2
|
||||
#define DHCP_REQUEST 3
|
||||
#define DHCP_DECLINE 4
|
||||
#define DHCP_ACK 5
|
||||
#define DHCP_NAK 6
|
||||
#define DHCP_RELEASE 7
|
||||
#define DHCP_INFORM 8
|
||||
|
||||
#define DHCP_HTYPE10MB 1
|
||||
#define DHCP_HTYPE100MB 2
|
||||
|
||||
#define DHCP_HLENETHERNET 6
|
||||
#define DHCP_HOPS 0
|
||||
#define DHCP_SECS 0
|
||||
|
||||
#define MAGIC_COOKIE 0x63825363
|
||||
#define MAX_DHCP_OPT 16
|
||||
|
||||
#define HOST_NAME "WIZnet"
|
||||
#define DEFAULT_LEASE (900) //default lease time in seconds
|
||||
|
||||
#define DHCP_CHECK_NONE (0)
|
||||
#define DHCP_CHECK_RENEW_FAIL (1)
|
||||
#define DHCP_CHECK_RENEW_OK (2)
|
||||
#define DHCP_CHECK_REBIND_FAIL (3)
|
||||
#define DHCP_CHECK_REBIND_OK (4)
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
typedef struct _RIP_MSG_FIXED
|
||||
{
|
||||
uint8_t op;
|
||||
uint8_t htype;
|
||||
uint8_t hlen;
|
||||
uint8_t hops;
|
||||
uint32_t xid;
|
||||
uint16_t secs;
|
||||
uint16_t flags;
|
||||
uint8_t ciaddr[4];
|
||||
uint8_t yiaddr[4];
|
||||
uint8_t siaddr[4];
|
||||
uint8_t giaddr[4];
|
||||
uint8_t chaddr[6];
|
||||
}RIP_MSG_FIXED;
|
||||
|
||||
class DhcpClass {
|
||||
private:
|
||||
uint32_t _dhcpInitialTransactionId;
|
||||
uint32_t _dhcpTransactionId;
|
||||
uint8_t _dhcpMacAddr[6];
|
||||
#ifdef __arm__
|
||||
uint8_t _dhcpLocalIp[4] __attribute__((aligned(4)));
|
||||
uint8_t _dhcpSubnetMask[4] __attribute__((aligned(4)));
|
||||
uint8_t _dhcpGatewayIp[4] __attribute__((aligned(4)));
|
||||
uint8_t _dhcpDhcpServerIp[4] __attribute__((aligned(4)));
|
||||
uint8_t _dhcpDnsServerIp[4] __attribute__((aligned(4)));
|
||||
#else
|
||||
uint8_t _dhcpLocalIp[4];
|
||||
uint8_t _dhcpSubnetMask[4];
|
||||
uint8_t _dhcpGatewayIp[4];
|
||||
uint8_t _dhcpDhcpServerIp[4];
|
||||
uint8_t _dhcpDnsServerIp[4];
|
||||
#endif
|
||||
uint32_t _dhcpLeaseTime;
|
||||
uint32_t _dhcpT1, _dhcpT2;
|
||||
signed long _renewInSec;
|
||||
signed long _rebindInSec;
|
||||
signed long _lastCheck;
|
||||
unsigned long _timeout;
|
||||
unsigned long _responseTimeout;
|
||||
unsigned long _secTimeout;
|
||||
uint8_t _dhcp_state;
|
||||
EthernetUDP _dhcpUdpSocket;
|
||||
|
||||
int request_DHCP_lease();
|
||||
void reset_DHCP_lease();
|
||||
void presend_DHCP();
|
||||
void send_DHCP_MESSAGE(uint8_t, uint16_t);
|
||||
void printByte(char *, uint8_t);
|
||||
|
||||
uint8_t parseDHCPResponse(unsigned long responseTimeout, uint32_t& transactionId);
|
||||
public:
|
||||
IPAddress getLocalIp();
|
||||
IPAddress getSubnetMask();
|
||||
IPAddress getGatewayIp();
|
||||
IPAddress getDhcpServerIp();
|
||||
IPAddress getDnsServerIp();
|
||||
|
||||
int beginWithDHCP(uint8_t *, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
|
||||
int checkLease();
|
||||
};
|
||||
|
||||
#endif
|
423
Ethernet/Dns.cpp
Normal file
423
Ethernet/Dns.cpp
Normal file
@ -0,0 +1,423 @@
|
||||
// Arduino DNS client for WizNet5100-based Ethernet shield
|
||||
// (c) Copyright 2009-2010 MCQN Ltd.
|
||||
// Released under Apache License, version 2.0
|
||||
|
||||
#include "w5100.h"
|
||||
#include "EthernetUdp.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "Dns.h"
|
||||
#include <string.h>
|
||||
//#include <stdlib.h>
|
||||
#include "Arduino.h"
|
||||
|
||||
|
||||
#define SOCKET_NONE 255
|
||||
// Various flags and header field values for a DNS message
|
||||
#define UDP_HEADER_SIZE 8
|
||||
#define DNS_HEADER_SIZE 12
|
||||
#define TTL_SIZE 4
|
||||
#define QUERY_FLAG (0)
|
||||
#define RESPONSE_FLAG (1<<15)
|
||||
#define QUERY_RESPONSE_MASK (1<<15)
|
||||
#define OPCODE_STANDARD_QUERY (0)
|
||||
#define OPCODE_INVERSE_QUERY (1<<11)
|
||||
#define OPCODE_STATUS_REQUEST (2<<11)
|
||||
#define OPCODE_MASK (15<<11)
|
||||
#define AUTHORITATIVE_FLAG (1<<10)
|
||||
#define TRUNCATION_FLAG (1<<9)
|
||||
#define RECURSION_DESIRED_FLAG (1<<8)
|
||||
#define RECURSION_AVAILABLE_FLAG (1<<7)
|
||||
#define RESP_NO_ERROR (0)
|
||||
#define RESP_FORMAT_ERROR (1)
|
||||
#define RESP_SERVER_FAILURE (2)
|
||||
#define RESP_NAME_ERROR (3)
|
||||
#define RESP_NOT_IMPLEMENTED (4)
|
||||
#define RESP_REFUSED (5)
|
||||
#define RESP_MASK (15)
|
||||
#define TYPE_A (0x0001)
|
||||
#define CLASS_IN (0x0001)
|
||||
#define LABEL_COMPRESSION_MASK (0xC0)
|
||||
// Port number that DNS servers listen on
|
||||
#define DNS_PORT 53
|
||||
|
||||
// Possible return codes from ProcessResponse
|
||||
#define SUCCESS 1
|
||||
#define TIMED_OUT -1
|
||||
#define INVALID_SERVER -2
|
||||
#define TRUNCATED -3
|
||||
#define INVALID_RESPONSE -4
|
||||
|
||||
void DNSClient::begin(const IPAddress& aDNSServer)
|
||||
{
|
||||
iDNSServer = aDNSServer;
|
||||
iRequestId = 0;
|
||||
}
|
||||
|
||||
|
||||
int DNSClient::inet_aton(const char* aIPAddrString, IPAddress& aResult)
|
||||
{
|
||||
// See if we've been given a valid IP address
|
||||
const char* p =aIPAddrString;
|
||||
while (*p &&
|
||||
( (*p == '.') || (*p >= '0') || (*p <= '9') ))
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
if (*p == '\0')
|
||||
{
|
||||
// It's looking promising, we haven't found any invalid characters
|
||||
p = aIPAddrString;
|
||||
int segment =0;
|
||||
int segmentValue =0;
|
||||
while (*p && (segment < 4))
|
||||
{
|
||||
if (*p == '.')
|
||||
{
|
||||
// We've reached the end of a segment
|
||||
if (segmentValue > 255)
|
||||
{
|
||||
// You can't have IP address segments that don't fit in a byte
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aResult[segment] = (byte)segmentValue;
|
||||
segment++;
|
||||
segmentValue = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Next digit
|
||||
segmentValue = (segmentValue*10)+(*p - '0');
|
||||
}
|
||||
p++;
|
||||
}
|
||||
// We've reached the end of address, but there'll still be the last
|
||||
// segment to deal with
|
||||
if ((segmentValue > 255) || (segment > 3))
|
||||
{
|
||||
// You can't have IP address segments that don't fit in a byte,
|
||||
// or more than four segments
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aResult[segment] = (byte)segmentValue;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int DNSClient::getHostByName(const char* aHostname, IPAddress& aResult)
|
||||
{
|
||||
int ret =0;
|
||||
|
||||
// See if it's a numeric IP address
|
||||
if (inet_aton(aHostname, aResult))
|
||||
{
|
||||
// It is, our work here is done
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Check we've got a valid DNS server to use
|
||||
if (iDNSServer == INADDR_NONE)
|
||||
{
|
||||
return INVALID_SERVER;
|
||||
}
|
||||
|
||||
// Find a socket to use
|
||||
if (iUdp.begin(1024+(millis() & 0xF)) == 1)
|
||||
{
|
||||
// Try up to three times
|
||||
int retries = 0;
|
||||
// while ((retries < 3) && (ret <= 0))
|
||||
{
|
||||
// Send DNS request
|
||||
ret = iUdp.beginPacket(iDNSServer, DNS_PORT);
|
||||
if (ret != 0)
|
||||
{
|
||||
// Now output the request data
|
||||
ret = BuildRequest(aHostname);
|
||||
if (ret != 0)
|
||||
{
|
||||
// And finally send the request
|
||||
ret = iUdp.endPacket();
|
||||
if (ret != 0)
|
||||
{
|
||||
// Now wait for a response
|
||||
int wait_retries = 0;
|
||||
ret = TIMED_OUT;
|
||||
while ((wait_retries < 3) && (ret == TIMED_OUT))
|
||||
{
|
||||
ret = ProcessResponse(5000, aResult);
|
||||
wait_retries++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
retries++;
|
||||
}
|
||||
|
||||
// We're done with the socket now
|
||||
iUdp.stop();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint16_t DNSClient::BuildRequest(const char* aName)
|
||||
{
|
||||
// Build header
|
||||
// 1 1 1 1 1 1
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
// | ID |
|
||||
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
// |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
|
||||
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
// | QDCOUNT |
|
||||
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
// | ANCOUNT |
|
||||
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
// | NSCOUNT |
|
||||
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
// | ARCOUNT |
|
||||
// +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
// As we only support one request at a time at present, we can simplify
|
||||
// some of this header
|
||||
iRequestId = millis(); // generate a random ID
|
||||
uint16_t twoByteBuffer;
|
||||
|
||||
// FIXME We should also check that there's enough space available to write to, rather
|
||||
// FIXME than assume there's enough space (as the code does at present)
|
||||
iUdp.write((uint8_t*)&iRequestId, sizeof(iRequestId));
|
||||
|
||||
twoByteBuffer = htons(QUERY_FLAG | OPCODE_STANDARD_QUERY | RECURSION_DESIRED_FLAG);
|
||||
iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer));
|
||||
|
||||
twoByteBuffer = htons(1); // One question record
|
||||
iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer));
|
||||
|
||||
twoByteBuffer = 0; // Zero answer records
|
||||
iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer));
|
||||
|
||||
iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer));
|
||||
// and zero additional records
|
||||
iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer));
|
||||
|
||||
// Build question
|
||||
const char* start =aName;
|
||||
const char* end =start;
|
||||
uint8_t len;
|
||||
// Run through the name being requested
|
||||
while (*end)
|
||||
{
|
||||
// Find out how long this section of the name is
|
||||
end = start;
|
||||
while (*end && (*end != '.') )
|
||||
{
|
||||
end++;
|
||||
}
|
||||
|
||||
if (end-start > 0)
|
||||
{
|
||||
// Write out the size of this section
|
||||
len = end-start;
|
||||
iUdp.write(&len, sizeof(len));
|
||||
// And then write out the section
|
||||
iUdp.write((uint8_t*)start, end-start);
|
||||
}
|
||||
start = end+1;
|
||||
}
|
||||
|
||||
// We've got to the end of the question name, so
|
||||
// terminate it with a zero-length section
|
||||
len = 0;
|
||||
iUdp.write(&len, sizeof(len));
|
||||
// Finally the type and class of question
|
||||
twoByteBuffer = htons(TYPE_A);
|
||||
iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer));
|
||||
|
||||
twoByteBuffer = htons(CLASS_IN); // Internet class of question
|
||||
iUdp.write((uint8_t*)&twoByteBuffer, sizeof(twoByteBuffer));
|
||||
// Success! Everything buffered okay
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
uint16_t DNSClient::ProcessResponse(uint16_t aTimeout, IPAddress& aAddress)
|
||||
{
|
||||
uint32_t startTime = millis();
|
||||
|
||||
// Wait for a response packet
|
||||
while(iUdp.parsePacket() <= 0)
|
||||
{
|
||||
if((millis() - startTime) > aTimeout)
|
||||
return TIMED_OUT;
|
||||
delay(50);
|
||||
}
|
||||
|
||||
// We've had a reply!
|
||||
// Read the UDP header
|
||||
uint8_t header[DNS_HEADER_SIZE]; // Enough space to reuse for the DNS header
|
||||
// Check that it's a response from the right server and the right port
|
||||
if ( (iDNSServer != iUdp.remoteIP()) ||
|
||||
(iUdp.remotePort() != DNS_PORT) )
|
||||
{
|
||||
// It's not from who we expected
|
||||
return INVALID_SERVER;
|
||||
}
|
||||
|
||||
// Read through the rest of the response
|
||||
if (iUdp.available() < DNS_HEADER_SIZE)
|
||||
{
|
||||
return TRUNCATED;
|
||||
}
|
||||
iUdp.read(header, DNS_HEADER_SIZE);
|
||||
|
||||
uint16_t header_flags = htons(*((uint16_t*)&header[2]));
|
||||
// Check that it's a response to this request
|
||||
if ( ( iRequestId != (*((uint16_t*)&header[0])) ) ||
|
||||
((header_flags & QUERY_RESPONSE_MASK) != (uint16_t)RESPONSE_FLAG) )
|
||||
{
|
||||
// Mark the entire packet as read
|
||||
iUdp.flush();
|
||||
return INVALID_RESPONSE;
|
||||
}
|
||||
// Check for any errors in the response (or in our request)
|
||||
// although we don't do anything to get round these
|
||||
if ( (header_flags & TRUNCATION_FLAG) || (header_flags & RESP_MASK) )
|
||||
{
|
||||
// Mark the entire packet as read
|
||||
iUdp.flush();
|
||||
return -5; //INVALID_RESPONSE;
|
||||
}
|
||||
|
||||
// And make sure we've got (at least) one answer
|
||||
uint16_t answerCount = htons(*((uint16_t*)&header[6]));
|
||||
if (answerCount == 0 )
|
||||
{
|
||||
// Mark the entire packet as read
|
||||
iUdp.flush();
|
||||
return -6; //INVALID_RESPONSE;
|
||||
}
|
||||
|
||||
// Skip over any questions
|
||||
for (uint16_t i =0; i < htons(*((uint16_t*)&header[4])); i++)
|
||||
{
|
||||
// Skip over the name
|
||||
uint8_t len;
|
||||
do
|
||||
{
|
||||
iUdp.read(&len, sizeof(len));
|
||||
if (len > 0)
|
||||
{
|
||||
// Don't need to actually read the data out for the string, just
|
||||
// advance ptr to beyond it
|
||||
while(len--)
|
||||
{
|
||||
iUdp.read(); // we don't care about the returned byte
|
||||
}
|
||||
}
|
||||
} while (len != 0);
|
||||
|
||||
// Now jump over the type and class
|
||||
for (int i =0; i < 4; i++)
|
||||
{
|
||||
iUdp.read(); // we don't care about the returned byte
|
||||
}
|
||||
}
|
||||
|
||||
// Now we're up to the bit we're interested in, the answer
|
||||
// There might be more than one answer (although we'll just use the first
|
||||
// type A answer) and some authority and additional resource records but
|
||||
// we're going to ignore all of them.
|
||||
|
||||
for (uint16_t i =0; i < answerCount; i++)
|
||||
{
|
||||
// Skip the name
|
||||
uint8_t len;
|
||||
do
|
||||
{
|
||||
iUdp.read(&len, sizeof(len));
|
||||
if ((len & LABEL_COMPRESSION_MASK) == 0)
|
||||
{
|
||||
// It's just a normal label
|
||||
if (len > 0)
|
||||
{
|
||||
// And it's got a length
|
||||
// Don't need to actually read the data out for the string,
|
||||
// just advance ptr to beyond it
|
||||
while(len--)
|
||||
{
|
||||
iUdp.read(); // we don't care about the returned byte
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is a pointer to a somewhere else in the message for the
|
||||
// rest of the name. We don't care about the name, and RFC1035
|
||||
// says that a name is either a sequence of labels ended with a
|
||||
// 0 length octet or a pointer or a sequence of labels ending in
|
||||
// a pointer. Either way, when we get here we're at the end of
|
||||
// the name
|
||||
// Skip over the pointer
|
||||
iUdp.read(); // we don't care about the returned byte
|
||||
// And set len so that we drop out of the name loop
|
||||
len = 0;
|
||||
}
|
||||
} while (len != 0);
|
||||
|
||||
// Check the type and class
|
||||
uint16_t answerType;
|
||||
uint16_t answerClass;
|
||||
iUdp.read((uint8_t*)&answerType, sizeof(answerType));
|
||||
iUdp.read((uint8_t*)&answerClass, sizeof(answerClass));
|
||||
|
||||
// Ignore the Time-To-Live as we don't do any caching
|
||||
for (int i =0; i < TTL_SIZE; i++)
|
||||
{
|
||||
iUdp.read(); // we don't care about the returned byte
|
||||
}
|
||||
|
||||
// And read out the length of this answer
|
||||
// Don't need header_flags anymore, so we can reuse it here
|
||||
iUdp.read((uint8_t*)&header_flags, sizeof(header_flags));
|
||||
|
||||
if ( (htons(answerType) == TYPE_A) && (htons(answerClass) == CLASS_IN) )
|
||||
{
|
||||
if (htons(header_flags) != 4)
|
||||
{
|
||||
// It's a weird size
|
||||
// Mark the entire packet as read
|
||||
iUdp.flush();
|
||||
return -9;//INVALID_RESPONSE;
|
||||
}
|
||||
iUdp.read(aAddress.raw_address(), 4);
|
||||
return SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This isn't an answer type we're after, move onto the next one
|
||||
for (uint16_t i =0; i < htons(header_flags); i++)
|
||||
{
|
||||
iUdp.read(); // we don't care about the returned byte
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the entire packet as read
|
||||
iUdp.flush();
|
||||
|
||||
// If we get here then we haven't found an answer
|
||||
return -10;//INVALID_RESPONSE;
|
||||
}
|
||||
|
41
Ethernet/Dns.h
Normal file
41
Ethernet/Dns.h
Normal file
@ -0,0 +1,41 @@
|
||||
// Arduino DNS client for WizNet5100-based Ethernet shield
|
||||
// (c) Copyright 2009-2010 MCQN Ltd.
|
||||
// Released under Apache License, version 2.0
|
||||
|
||||
#ifndef DNSClient_h
|
||||
#define DNSClient_h
|
||||
|
||||
#include <EthernetUdp.h>
|
||||
|
||||
class DNSClient
|
||||
{
|
||||
public:
|
||||
// ctor
|
||||
void begin(const IPAddress& aDNSServer);
|
||||
|
||||
/** Convert a numeric IP address string into a four-byte IP address.
|
||||
@param aIPAddrString IP address to convert
|
||||
@param aResult IPAddress structure to store the returned IP address
|
||||
@result 1 if aIPAddrString was successfully converted to an IP address,
|
||||
else error code
|
||||
*/
|
||||
int inet_aton(const char *aIPAddrString, IPAddress& aResult);
|
||||
|
||||
/** Resolve the given hostname to an IP address.
|
||||
@param aHostname Name to be resolved
|
||||
@param aResult IPAddress structure to store the returned IP address
|
||||
@result 1 if aIPAddrString was successfully converted to an IP address,
|
||||
else error code
|
||||
*/
|
||||
int getHostByName(const char* aHostname, IPAddress& aResult);
|
||||
|
||||
protected:
|
||||
uint16_t BuildRequest(const char* aName);
|
||||
uint16_t ProcessResponse(uint16_t aTimeout, IPAddress& aAddress);
|
||||
|
||||
IPAddress iDNSServer;
|
||||
uint16_t iRequestId;
|
||||
EthernetUDP iUdp;
|
||||
};
|
||||
|
||||
#endif
|
136
Ethernet/Ethernet.cpp
Normal file
136
Ethernet/Ethernet.cpp
Normal file
@ -0,0 +1,136 @@
|
||||
#include "w5100.h"
|
||||
#include "Ethernet.h"
|
||||
#include "Dhcp.h"
|
||||
|
||||
// XXX: don't make assumptions about the value of MAX_SOCK_NUM.
|
||||
uint8_t EthernetClass::_state[MAX_SOCK_NUM] = {
|
||||
0, 0, 0, 0 };
|
||||
uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = {
|
||||
0, 0, 0, 0 };
|
||||
|
||||
int EthernetClass::begin(uint8_t *mac_address)
|
||||
{
|
||||
static DhcpClass s_dhcp;
|
||||
_dhcp = &s_dhcp;
|
||||
|
||||
|
||||
// Initialise the basic info
|
||||
W5100.init();
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.setMACAddress(mac_address);
|
||||
W5100.setIPAddress(IPAddress(0,0,0,0).raw_address());
|
||||
SPI.endTransaction();
|
||||
|
||||
// Now try to get our config info from a DHCP server
|
||||
int ret = _dhcp->beginWithDHCP(mac_address);
|
||||
if(ret == 1)
|
||||
{
|
||||
// We've successfully found a DHCP server and got our configuration info, so set things
|
||||
// accordingly
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.setIPAddress(_dhcp->getLocalIp().raw_address());
|
||||
W5100.setGatewayIp(_dhcp->getGatewayIp().raw_address());
|
||||
W5100.setSubnetMask(_dhcp->getSubnetMask().raw_address());
|
||||
SPI.endTransaction();
|
||||
_dnsServerAddress = _dhcp->getDnsServerIp();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip)
|
||||
{
|
||||
// Assume the DNS server will be the machine on the same network as the local IP
|
||||
// but with last octet being '1'
|
||||
IPAddress dns_server = local_ip;
|
||||
dns_server[3] = 1;
|
||||
begin(mac_address, local_ip, dns_server);
|
||||
}
|
||||
|
||||
void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server)
|
||||
{
|
||||
// Assume the gateway will be the machine on the same network as the local IP
|
||||
// but with last octet being '1'
|
||||
IPAddress gateway = local_ip;
|
||||
gateway[3] = 1;
|
||||
begin(mac_address, local_ip, dns_server, gateway);
|
||||
}
|
||||
|
||||
void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway)
|
||||
{
|
||||
IPAddress subnet(255, 255, 255, 0);
|
||||
begin(mac_address, local_ip, dns_server, gateway, subnet);
|
||||
}
|
||||
|
||||
void EthernetClass::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
|
||||
{
|
||||
W5100.init();
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.setMACAddress(mac);
|
||||
W5100.setIPAddress(local_ip._address);
|
||||
W5100.setGatewayIp(gateway._address);
|
||||
W5100.setSubnetMask(subnet._address);
|
||||
SPI.endTransaction();
|
||||
_dnsServerAddress = dns_server;
|
||||
}
|
||||
|
||||
int EthernetClass::maintain(){
|
||||
int rc = DHCP_CHECK_NONE;
|
||||
if(_dhcp != NULL){
|
||||
//we have a pointer to dhcp, use it
|
||||
rc = _dhcp->checkLease();
|
||||
switch ( rc ){
|
||||
case DHCP_CHECK_NONE:
|
||||
//nothing done
|
||||
break;
|
||||
case DHCP_CHECK_RENEW_OK:
|
||||
case DHCP_CHECK_REBIND_OK:
|
||||
//we might have got a new IP.
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.setIPAddress(_dhcp->getLocalIp().raw_address());
|
||||
W5100.setGatewayIp(_dhcp->getGatewayIp().raw_address());
|
||||
W5100.setSubnetMask(_dhcp->getSubnetMask().raw_address());
|
||||
SPI.endTransaction();
|
||||
_dnsServerAddress = _dhcp->getDnsServerIp();
|
||||
break;
|
||||
default:
|
||||
//this is actually a error, it will retry though
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
IPAddress EthernetClass::localIP()
|
||||
{
|
||||
IPAddress ret;
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.getIPAddress(ret.raw_address());
|
||||
SPI.endTransaction();
|
||||
return ret;
|
||||
}
|
||||
|
||||
IPAddress EthernetClass::subnetMask()
|
||||
{
|
||||
IPAddress ret;
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.getSubnetMask(ret.raw_address());
|
||||
SPI.endTransaction();
|
||||
return ret;
|
||||
}
|
||||
|
||||
IPAddress EthernetClass::gatewayIP()
|
||||
{
|
||||
IPAddress ret;
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.getGatewayIp(ret.raw_address());
|
||||
SPI.endTransaction();
|
||||
return ret;
|
||||
}
|
||||
|
||||
IPAddress EthernetClass::dnsServerIP()
|
||||
{
|
||||
return _dnsServerAddress;
|
||||
}
|
||||
|
||||
EthernetClass Ethernet;
|
41
Ethernet/Ethernet.h
Normal file
41
Ethernet/Ethernet.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef ethernet_h
|
||||
#define ethernet_h
|
||||
|
||||
#include <inttypes.h>
|
||||
//#include "w5100.h"
|
||||
#include "IPAddress.h"
|
||||
#include "EthernetClient.h"
|
||||
#include "EthernetServer.h"
|
||||
#include "Dhcp.h"
|
||||
|
||||
#define MAX_SOCK_NUM 4
|
||||
|
||||
class EthernetClass {
|
||||
private:
|
||||
IPAddress _dnsServerAddress;
|
||||
DhcpClass* _dhcp;
|
||||
public:
|
||||
static uint8_t _state[MAX_SOCK_NUM];
|
||||
static uint16_t _server_port[MAX_SOCK_NUM];
|
||||
// Initialise the Ethernet shield to use the provided MAC address and gain the rest of the
|
||||
// configuration through DHCP.
|
||||
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
|
||||
int begin(uint8_t *mac_address);
|
||||
void begin(uint8_t *mac_address, IPAddress local_ip);
|
||||
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server);
|
||||
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
|
||||
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);
|
||||
int maintain();
|
||||
|
||||
IPAddress localIP();
|
||||
IPAddress subnetMask();
|
||||
IPAddress gatewayIP();
|
||||
IPAddress dnsServerIP();
|
||||
|
||||
friend class EthernetClient;
|
||||
friend class EthernetServer;
|
||||
};
|
||||
|
||||
extern EthernetClass Ethernet;
|
||||
|
||||
#endif
|
165
Ethernet/EthernetClient.cpp
Normal file
165
Ethernet/EthernetClient.cpp
Normal file
@ -0,0 +1,165 @@
|
||||
#include "w5100.h"
|
||||
#include "socket.h"
|
||||
|
||||
extern "C" {
|
||||
#include "string.h"
|
||||
}
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#include "Ethernet.h"
|
||||
#include "EthernetClient.h"
|
||||
#include "EthernetServer.h"
|
||||
#include "Dns.h"
|
||||
|
||||
uint16_t EthernetClient::_srcport = 1024;
|
||||
|
||||
EthernetClient::EthernetClient() : _sock(MAX_SOCK_NUM) {
|
||||
}
|
||||
|
||||
EthernetClient::EthernetClient(uint8_t sock) : _sock(sock) {
|
||||
}
|
||||
|
||||
int EthernetClient::connect(const char* host, uint16_t port) {
|
||||
// Look up the host first
|
||||
int ret = 0;
|
||||
DNSClient dns;
|
||||
IPAddress remote_addr;
|
||||
|
||||
dns.begin(Ethernet.dnsServerIP());
|
||||
ret = dns.getHostByName(host, remote_addr);
|
||||
if (ret == 1) {
|
||||
return connect(remote_addr, port);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
int EthernetClient::connect(IPAddress ip, uint16_t port) {
|
||||
if (_sock != MAX_SOCK_NUM)
|
||||
return 0;
|
||||
|
||||
for (int i = 0; i < MAX_SOCK_NUM; i++) {
|
||||
uint8_t s = socketStatus(i);
|
||||
if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT || s == SnSR::CLOSE_WAIT) {
|
||||
_sock = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_sock == MAX_SOCK_NUM)
|
||||
return 0;
|
||||
|
||||
_srcport++;
|
||||
if (_srcport == 0) _srcport = 1024;
|
||||
socket(_sock, SnMR::TCP, _srcport, 0);
|
||||
|
||||
if (!::connect(_sock, rawIPAddress(ip), port)) {
|
||||
_sock = MAX_SOCK_NUM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (status() != SnSR::ESTABLISHED) {
|
||||
delay(1);
|
||||
if (status() == SnSR::CLOSED) {
|
||||
_sock = MAX_SOCK_NUM;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t EthernetClient::write(uint8_t b) {
|
||||
return write(&b, 1);
|
||||
}
|
||||
|
||||
size_t EthernetClient::write(const uint8_t *buf, size_t size) {
|
||||
if (_sock == MAX_SOCK_NUM) {
|
||||
setWriteError();
|
||||
return 0;
|
||||
}
|
||||
if (!send(_sock, buf, size)) {
|
||||
setWriteError();
|
||||
return 0;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
int EthernetClient::available() {
|
||||
if (_sock != MAX_SOCK_NUM)
|
||||
return recvAvailable(_sock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EthernetClient::read() {
|
||||
uint8_t b;
|
||||
if ( recv(_sock, &b, 1) > 0 )
|
||||
{
|
||||
// recv worked
|
||||
return b;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No data available
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int EthernetClient::read(uint8_t *buf, size_t size) {
|
||||
return recv(_sock, buf, size);
|
||||
}
|
||||
|
||||
int EthernetClient::peek() {
|
||||
uint8_t b;
|
||||
// Unlike recv, peek doesn't check to see if there's any data available, so we must
|
||||
if (!available())
|
||||
return -1;
|
||||
::peek(_sock, &b);
|
||||
return b;
|
||||
}
|
||||
|
||||
void EthernetClient::flush() {
|
||||
while (available())
|
||||
read();
|
||||
}
|
||||
|
||||
void EthernetClient::stop() {
|
||||
if (_sock == MAX_SOCK_NUM)
|
||||
return;
|
||||
|
||||
// attempt to close the connection gracefully (send a FIN to other side)
|
||||
disconnect(_sock);
|
||||
unsigned long start = millis();
|
||||
|
||||
// wait a second for the connection to close
|
||||
while (status() != SnSR::CLOSED && millis() - start < 1000)
|
||||
delay(1);
|
||||
|
||||
// if it hasn't closed, close it forcefully
|
||||
if (status() != SnSR::CLOSED)
|
||||
close(_sock);
|
||||
|
||||
EthernetClass::_server_port[_sock] = 0;
|
||||
_sock = MAX_SOCK_NUM;
|
||||
}
|
||||
|
||||
uint8_t EthernetClient::connected() {
|
||||
if (_sock == MAX_SOCK_NUM) return 0;
|
||||
|
||||
uint8_t s = status();
|
||||
return !(s == SnSR::LISTEN || s == SnSR::CLOSED || s == SnSR::FIN_WAIT ||
|
||||
(s == SnSR::CLOSE_WAIT && !available()));
|
||||
}
|
||||
|
||||
uint8_t EthernetClient::status() {
|
||||
if (_sock == MAX_SOCK_NUM) return SnSR::CLOSED;
|
||||
return socketStatus(_sock);
|
||||
}
|
||||
|
||||
// the next function allows us to use the client returned by
|
||||
// EthernetServer::available() as the condition in an if-statement.
|
||||
|
||||
EthernetClient::operator bool() {
|
||||
return _sock != MAX_SOCK_NUM;
|
||||
}
|
37
Ethernet/EthernetClient.h
Normal file
37
Ethernet/EthernetClient.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef ethernetclient_h
|
||||
#define ethernetclient_h
|
||||
#include "Arduino.h"
|
||||
#include "Print.h"
|
||||
#include "Client.h"
|
||||
#include "IPAddress.h"
|
||||
|
||||
class EthernetClient : public Client {
|
||||
|
||||
public:
|
||||
EthernetClient();
|
||||
EthernetClient(uint8_t sock);
|
||||
|
||||
uint8_t status();
|
||||
virtual int connect(IPAddress ip, uint16_t port);
|
||||
virtual int connect(const char *host, uint16_t port);
|
||||
virtual size_t write(uint8_t);
|
||||
virtual size_t write(const uint8_t *buf, size_t size);
|
||||
virtual int available();
|
||||
virtual int read();
|
||||
virtual int read(uint8_t *buf, size_t size);
|
||||
virtual int peek();
|
||||
virtual void flush();
|
||||
virtual void stop();
|
||||
virtual uint8_t connected();
|
||||
virtual operator bool();
|
||||
|
||||
friend class EthernetServer;
|
||||
|
||||
using Print::write;
|
||||
|
||||
private:
|
||||
static uint16_t _srcport;
|
||||
uint8_t _sock;
|
||||
};
|
||||
|
||||
#endif
|
91
Ethernet/EthernetServer.cpp
Normal file
91
Ethernet/EthernetServer.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include "w5100.h"
|
||||
#include "socket.h"
|
||||
extern "C" {
|
||||
#include "string.h"
|
||||
}
|
||||
|
||||
#include "Ethernet.h"
|
||||
#include "EthernetClient.h"
|
||||
#include "EthernetServer.h"
|
||||
|
||||
EthernetServer::EthernetServer(uint16_t port)
|
||||
{
|
||||
_port = port;
|
||||
}
|
||||
|
||||
void EthernetServer::begin()
|
||||
{
|
||||
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
||||
EthernetClient client(sock);
|
||||
if (client.status() == SnSR::CLOSED) {
|
||||
socket(sock, SnMR::TCP, _port, 0);
|
||||
listen(sock);
|
||||
EthernetClass::_server_port[sock] = _port;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EthernetServer::accept()
|
||||
{
|
||||
int listening = 0;
|
||||
|
||||
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
||||
EthernetClient client(sock);
|
||||
|
||||
if (EthernetClass::_server_port[sock] == _port) {
|
||||
if (client.status() == SnSR::LISTEN) {
|
||||
listening = 1;
|
||||
}
|
||||
else if (client.status() == SnSR::CLOSE_WAIT && !client.available()) {
|
||||
client.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!listening) {
|
||||
begin();
|
||||
}
|
||||
}
|
||||
|
||||
EthernetClient EthernetServer::available()
|
||||
{
|
||||
accept();
|
||||
|
||||
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
||||
EthernetClient client(sock);
|
||||
if (EthernetClass::_server_port[sock] == _port &&
|
||||
(client.status() == SnSR::ESTABLISHED ||
|
||||
client.status() == SnSR::CLOSE_WAIT)) {
|
||||
if (client.available()) {
|
||||
// XXX: don't always pick the lowest numbered socket.
|
||||
return client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EthernetClient(MAX_SOCK_NUM);
|
||||
}
|
||||
|
||||
size_t EthernetServer::write(uint8_t b)
|
||||
{
|
||||
return write(&b, 1);
|
||||
}
|
||||
|
||||
size_t EthernetServer::write(const uint8_t *buffer, size_t size)
|
||||
{
|
||||
size_t n = 0;
|
||||
|
||||
accept();
|
||||
|
||||
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
||||
EthernetClient client(sock);
|
||||
|
||||
if (EthernetClass::_server_port[sock] == _port &&
|
||||
client.status() == SnSR::ESTABLISHED) {
|
||||
n += client.write(buffer, size);
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
22
Ethernet/EthernetServer.h
Normal file
22
Ethernet/EthernetServer.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef ethernetserver_h
|
||||
#define ethernetserver_h
|
||||
|
||||
#include "Server.h"
|
||||
|
||||
class EthernetClient;
|
||||
|
||||
class EthernetServer :
|
||||
public Server {
|
||||
private:
|
||||
uint16_t _port;
|
||||
void accept();
|
||||
public:
|
||||
EthernetServer(uint16_t);
|
||||
EthernetClient available();
|
||||
virtual void begin();
|
||||
virtual size_t write(uint8_t);
|
||||
virtual size_t write(const uint8_t *buf, size_t size);
|
||||
using Print::write;
|
||||
};
|
||||
|
||||
#endif
|
218
Ethernet/EthernetUdp.cpp
Normal file
218
Ethernet/EthernetUdp.cpp
Normal file
@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield.
|
||||
* This version only offers minimal wrapping of socket.c/socket.h
|
||||
* Drop Udp.h/.cpp into the Ethernet library directory at hardware/libraries/Ethernet/
|
||||
*
|
||||
* MIT License:
|
||||
* Copyright (c) 2008 Bjoern Hartmann
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* bjoern@cs.stanford.edu 12/30/2008
|
||||
*/
|
||||
|
||||
#include "w5100.h"
|
||||
#include "socket.h"
|
||||
#include "Ethernet.h"
|
||||
#include "Udp.h"
|
||||
#include "Dns.h"
|
||||
|
||||
/* Constructor */
|
||||
EthernetUDP::EthernetUDP() : _sock(MAX_SOCK_NUM) {}
|
||||
|
||||
/* Start EthernetUDP socket, listening at local port PORT */
|
||||
uint8_t EthernetUDP::begin(uint16_t port) {
|
||||
if (_sock != MAX_SOCK_NUM)
|
||||
return 0;
|
||||
|
||||
for (int i = 0; i < MAX_SOCK_NUM; i++) {
|
||||
uint8_t s = socketStatus(i);
|
||||
if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT) {
|
||||
_sock = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_sock == MAX_SOCK_NUM)
|
||||
return 0;
|
||||
|
||||
_port = port;
|
||||
_remaining = 0;
|
||||
socket(_sock, SnMR::UDP, _port, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* return number of bytes available in the current packet,
|
||||
will return zero if parsePacket hasn't been called yet */
|
||||
int EthernetUDP::available() {
|
||||
return _remaining;
|
||||
}
|
||||
|
||||
/* Release any resources being used by this EthernetUDP instance */
|
||||
void EthernetUDP::stop()
|
||||
{
|
||||
if (_sock == MAX_SOCK_NUM)
|
||||
return;
|
||||
|
||||
close(_sock);
|
||||
|
||||
EthernetClass::_server_port[_sock] = 0;
|
||||
_sock = MAX_SOCK_NUM;
|
||||
}
|
||||
|
||||
int EthernetUDP::beginPacket(const char *host, uint16_t port)
|
||||
{
|
||||
// Look up the host first
|
||||
int ret = 0;
|
||||
DNSClient dns;
|
||||
IPAddress remote_addr;
|
||||
|
||||
dns.begin(Ethernet.dnsServerIP());
|
||||
ret = dns.getHostByName(host, remote_addr);
|
||||
if (ret == 1) {
|
||||
return beginPacket(remote_addr, port);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
int EthernetUDP::beginPacket(IPAddress ip, uint16_t port)
|
||||
{
|
||||
_offset = 0;
|
||||
return startUDP(_sock, rawIPAddress(ip), port);
|
||||
}
|
||||
|
||||
int EthernetUDP::endPacket()
|
||||
{
|
||||
return sendUDP(_sock);
|
||||
}
|
||||
|
||||
size_t EthernetUDP::write(uint8_t byte)
|
||||
{
|
||||
return write(&byte, 1);
|
||||
}
|
||||
|
||||
size_t EthernetUDP::write(const uint8_t *buffer, size_t size)
|
||||
{
|
||||
uint16_t bytes_written = bufferData(_sock, _offset, buffer, size);
|
||||
_offset += bytes_written;
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
int EthernetUDP::parsePacket()
|
||||
{
|
||||
// discard any remaining bytes in the last packet
|
||||
flush();
|
||||
|
||||
if (recvAvailable(_sock) > 0)
|
||||
{
|
||||
//HACK - hand-parse the UDP packet using TCP recv method
|
||||
uint8_t tmpBuf[8];
|
||||
int ret =0;
|
||||
//read 8 header bytes and get IP and port from it
|
||||
ret = recv(_sock,tmpBuf,8);
|
||||
if (ret > 0)
|
||||
{
|
||||
_remoteIP = tmpBuf;
|
||||
_remotePort = tmpBuf[4];
|
||||
_remotePort = (_remotePort << 8) + tmpBuf[5];
|
||||
_remaining = tmpBuf[6];
|
||||
_remaining = (_remaining << 8) + tmpBuf[7];
|
||||
|
||||
// When we get here, any remaining bytes are the data
|
||||
ret = _remaining;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
// There aren't any packets available
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EthernetUDP::read()
|
||||
{
|
||||
uint8_t byte;
|
||||
|
||||
if ((_remaining > 0) && (recv(_sock, &byte, 1) > 0))
|
||||
{
|
||||
// We read things without any problems
|
||||
_remaining--;
|
||||
return byte;
|
||||
}
|
||||
|
||||
// If we get here, there's no data available
|
||||
return -1;
|
||||
}
|
||||
|
||||
int EthernetUDP::read(unsigned char* buffer, size_t len)
|
||||
{
|
||||
|
||||
if (_remaining > 0)
|
||||
{
|
||||
|
||||
int got;
|
||||
|
||||
if (_remaining <= len)
|
||||
{
|
||||
// data should fit in the buffer
|
||||
got = recv(_sock, buffer, _remaining);
|
||||
}
|
||||
else
|
||||
{
|
||||
// too much data for the buffer,
|
||||
// grab as much as will fit
|
||||
got = recv(_sock, buffer, len);
|
||||
}
|
||||
|
||||
if (got > 0)
|
||||
{
|
||||
_remaining -= got;
|
||||
return got;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If we get here, there's no data available or recv failed
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
int EthernetUDP::peek()
|
||||
{
|
||||
uint8_t b;
|
||||
// Unlike recv, peek doesn't check to see if there's any data available, so we must.
|
||||
// If the user hasn't called parsePacket yet then return nothing otherwise they
|
||||
// may get the UDP header
|
||||
if (!_remaining)
|
||||
return -1;
|
||||
::peek(_sock, &b);
|
||||
return b;
|
||||
}
|
||||
|
||||
void EthernetUDP::flush()
|
||||
{
|
||||
// could this fail (loop endlessly) if _remaining > 0 and recv in read fails?
|
||||
// should only occur if recv fails after telling us the data is there, lets
|
||||
// hope the w5100 always behaves :)
|
||||
|
||||
while (_remaining)
|
||||
{
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
99
Ethernet/EthernetUdp.h
Normal file
99
Ethernet/EthernetUdp.h
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield.
|
||||
* This version only offers minimal wrapping of socket.c/socket.h
|
||||
* Drop Udp.h/.cpp into the Ethernet library directory at hardware/libraries/Ethernet/
|
||||
*
|
||||
* NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these)
|
||||
* 1) UDP does not guarantee the order in which assembled UDP packets are received. This
|
||||
* might not happen often in practice, but in larger network topologies, a UDP
|
||||
* packet can be received out of sequence.
|
||||
* 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being
|
||||
* aware of it. Again, this may not be a concern in practice on small local networks.
|
||||
* For more information, see http://www.cafeaulait.org/course/week12/35.html
|
||||
*
|
||||
* MIT License:
|
||||
* Copyright (c) 2008 Bjoern Hartmann
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* bjoern@cs.stanford.edu 12/30/2008
|
||||
*/
|
||||
|
||||
#ifndef ethernetudp_h
|
||||
#define ethernetudp_h
|
||||
|
||||
#include <Udp.h>
|
||||
|
||||
#define UDP_TX_PACKET_MAX_SIZE 24
|
||||
|
||||
class EthernetUDP : public UDP {
|
||||
private:
|
||||
uint8_t _sock; // socket ID for Wiz5100
|
||||
uint16_t _port; // local port to listen on
|
||||
IPAddress _remoteIP; // remote IP address for the incoming packet whilst it's being processed
|
||||
uint16_t _remotePort; // remote port for the incoming packet whilst it's being processed
|
||||
uint16_t _offset; // offset into the packet being sent
|
||||
uint16_t _remaining; // remaining bytes of incoming packet yet to be processed
|
||||
|
||||
public:
|
||||
EthernetUDP(); // Constructor
|
||||
virtual uint8_t begin(uint16_t); // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
|
||||
virtual void stop(); // Finish with the UDP socket
|
||||
|
||||
// Sending UDP packets
|
||||
|
||||
// Start building up a packet to send to the remote host specific in ip and port
|
||||
// Returns 1 if successful, 0 if there was a problem with the supplied IP address or port
|
||||
virtual int beginPacket(IPAddress ip, uint16_t port);
|
||||
// Start building up a packet to send to the remote host specific in host and port
|
||||
// Returns 1 if successful, 0 if there was a problem resolving the hostname or port
|
||||
virtual int beginPacket(const char *host, uint16_t port);
|
||||
// Finish off this packet and send it
|
||||
// Returns 1 if the packet was sent successfully, 0 if there was an error
|
||||
virtual int endPacket();
|
||||
// Write a single byte into the packet
|
||||
virtual size_t write(uint8_t);
|
||||
// Write size bytes from buffer into the packet
|
||||
virtual size_t write(const uint8_t *buffer, size_t size);
|
||||
|
||||
using Print::write;
|
||||
|
||||
// Start processing the next available incoming packet
|
||||
// Returns the size of the packet in bytes, or 0 if no packets are available
|
||||
virtual int parsePacket();
|
||||
// Number of bytes remaining in the current packet
|
||||
virtual int available();
|
||||
// Read a single byte from the current packet
|
||||
virtual int read();
|
||||
// Read up to len bytes from the current packet and place them into buffer
|
||||
// Returns the number of bytes read, or 0 if none are available
|
||||
virtual int read(unsigned char* buffer, size_t len);
|
||||
// Read up to len characters from the current packet and place them into buffer
|
||||
// Returns the number of characters read, or 0 if none are available
|
||||
virtual int read(char* buffer, size_t len) { return read((unsigned char*)buffer, len); };
|
||||
// Return the next byte from the current packet without moving on to the next byte
|
||||
virtual int peek();
|
||||
virtual void flush(); // Finish reading the current packet
|
||||
|
||||
// Return the IP address of the host who sent the current incoming packet
|
||||
virtual IPAddress remoteIP() { return _remoteIP; };
|
||||
// Return the port of the host who sent the current incoming packet
|
||||
virtual uint16_t remotePort() { return _remotePort; };
|
||||
};
|
||||
|
||||
#endif
|
13
Ethernet/util.h
Normal file
13
Ethernet/util.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) )
|
||||
#define ntohs(x) htons(x)
|
||||
|
||||
#define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
|
||||
((x)<< 8 & 0x00FF0000UL) | \
|
||||
((x)>> 8 & 0x0000FF00UL) | \
|
||||
((x)>>24 & 0x000000FFUL) )
|
||||
#define ntohl(x) htonl(x)
|
||||
|
||||
#endif
|
468
Ethernet/utility/socket.cpp
Normal file
468
Ethernet/utility/socket.cpp
Normal file
@ -0,0 +1,468 @@
|
||||
#include "w5100.h"
|
||||
#include "socket.h"
|
||||
|
||||
#if ARDUINO >= 156 || TEENSYDUINO >= 120
|
||||
extern void yield(void);
|
||||
#else
|
||||
#define yield()
|
||||
#endif
|
||||
|
||||
static uint16_t local_port;
|
||||
|
||||
/**
|
||||
* @brief This Socket function initialize the channel in perticular mode, and set the port and wait for W5100 done it.
|
||||
* @return 1 for success else 0.
|
||||
*/
|
||||
uint8_t socket(SOCKET s, uint8_t protocol, uint16_t port, uint8_t flag)
|
||||
{
|
||||
if ((protocol == SnMR::TCP) || (protocol == SnMR::UDP) || (protocol == SnMR::IPRAW) || (protocol == SnMR::MACRAW) || (protocol == SnMR::PPPOE))
|
||||
{
|
||||
close(s);
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.writeSnMR(s, protocol | flag);
|
||||
if (port != 0) {
|
||||
W5100.writeSnPORT(s, port);
|
||||
}
|
||||
else {
|
||||
local_port++; // if don't set the source port, set local_port number.
|
||||
W5100.writeSnPORT(s, local_port);
|
||||
}
|
||||
W5100.execCmdSn(s, Sock_OPEN);
|
||||
SPI.endTransaction();
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint8_t socketStatus(SOCKET s)
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
uint8_t status = W5100.readSnSR(s);
|
||||
SPI.endTransaction();
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function close the socket and parameter is "s" which represent the socket number
|
||||
*/
|
||||
void close(SOCKET s)
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.execCmdSn(s, Sock_CLOSE);
|
||||
W5100.writeSnIR(s, 0xFF);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function established the connection for the channel in passive (server) mode. This function waits for the request from the peer.
|
||||
* @return 1 for success else 0.
|
||||
*/
|
||||
uint8_t listen(SOCKET s)
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
if (W5100.readSnSR(s) != SnSR::INIT) {
|
||||
SPI.endTransaction();
|
||||
return 0;
|
||||
}
|
||||
W5100.execCmdSn(s, Sock_LISTEN);
|
||||
SPI.endTransaction();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function established the connection for the channel in Active (client) mode.
|
||||
* This function waits for the untill the connection is established.
|
||||
*
|
||||
* @return 1 for success else 0.
|
||||
*/
|
||||
uint8_t connect(SOCKET s, uint8_t * addr, uint16_t port)
|
||||
{
|
||||
if
|
||||
(
|
||||
((addr[0] == 0xFF) && (addr[1] == 0xFF) && (addr[2] == 0xFF) && (addr[3] == 0xFF)) ||
|
||||
((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) ||
|
||||
(port == 0x00)
|
||||
)
|
||||
return 0;
|
||||
|
||||
// set destination IP
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.writeSnDIPR(s, addr);
|
||||
W5100.writeSnDPORT(s, port);
|
||||
W5100.execCmdSn(s, Sock_CONNECT);
|
||||
SPI.endTransaction();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function used for disconnect the socket and parameter is "s" which represent the socket number
|
||||
* @return 1 for success else 0.
|
||||
*/
|
||||
void disconnect(SOCKET s)
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.execCmdSn(s, Sock_DISCON);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function used to send the data in TCP mode
|
||||
* @return 1 for success else 0.
|
||||
*/
|
||||
uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len)
|
||||
{
|
||||
uint8_t status=0;
|
||||
uint16_t ret=0;
|
||||
uint16_t freesize=0;
|
||||
|
||||
if (len > W5100.SSIZE)
|
||||
ret = W5100.SSIZE; // check size not to exceed MAX size.
|
||||
else
|
||||
ret = len;
|
||||
|
||||
// if freebuf is available, start.
|
||||
do
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
freesize = W5100.getTXFreeSize(s);
|
||||
status = W5100.readSnSR(s);
|
||||
SPI.endTransaction();
|
||||
if ((status != SnSR::ESTABLISHED) && (status != SnSR::CLOSE_WAIT))
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
yield();
|
||||
}
|
||||
while (freesize < ret);
|
||||
|
||||
// copy data
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.send_data_processing(s, (uint8_t *)buf, ret);
|
||||
W5100.execCmdSn(s, Sock_SEND);
|
||||
|
||||
/* +2008.01 bj */
|
||||
while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK )
|
||||
{
|
||||
/* m2008.01 [bj] : reduce code */
|
||||
if ( W5100.readSnSR(s) == SnSR::CLOSED )
|
||||
{
|
||||
SPI.endTransaction();
|
||||
close(s);
|
||||
return 0;
|
||||
}
|
||||
SPI.endTransaction();
|
||||
yield();
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
}
|
||||
/* +2008.01 bj */
|
||||
W5100.writeSnIR(s, SnIR::SEND_OK);
|
||||
SPI.endTransaction();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is an application I/F function which is used to receive the data in TCP mode.
|
||||
* It continues to wait for data as much as the application wants to receive.
|
||||
*
|
||||
* @return received data size for success else -1.
|
||||
*/
|
||||
int16_t recv(SOCKET s, uint8_t *buf, int16_t len)
|
||||
{
|
||||
// Check how much data is available
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
int16_t ret = W5100.getRXReceivedSize(s);
|
||||
if ( ret == 0 )
|
||||
{
|
||||
// No data available.
|
||||
uint8_t status = W5100.readSnSR(s);
|
||||
if ( status == SnSR::LISTEN || status == SnSR::CLOSED || status == SnSR::CLOSE_WAIT )
|
||||
{
|
||||
// The remote end has closed its side of the connection, so this is the eof state
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The connection is still up, but there's no data waiting to be read
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
else if (ret > len)
|
||||
{
|
||||
ret = len;
|
||||
}
|
||||
|
||||
if ( ret > 0 )
|
||||
{
|
||||
W5100.recv_data_processing(s, buf, ret);
|
||||
W5100.execCmdSn(s, Sock_RECV);
|
||||
}
|
||||
SPI.endTransaction();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int16_t recvAvailable(SOCKET s)
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
int16_t ret = W5100.getRXReceivedSize(s);
|
||||
SPI.endTransaction();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns the first byte in the receive queue (no checking)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
uint16_t peek(SOCKET s, uint8_t *buf)
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.recv_data_processing(s, buf, 1, 1);
|
||||
SPI.endTransaction();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is an application I/F function which is used to send the data for other then TCP mode.
|
||||
* Unlike TCP transmission, The peer's destination address and the port is needed.
|
||||
*
|
||||
* @return This function return send data size for success else -1.
|
||||
*/
|
||||
uint16_t sendto(SOCKET s, const uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t port)
|
||||
{
|
||||
uint16_t ret=0;
|
||||
|
||||
if (len > W5100.SSIZE) ret = W5100.SSIZE; // check size not to exceed MAX size.
|
||||
else ret = len;
|
||||
|
||||
if
|
||||
(
|
||||
((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) ||
|
||||
((port == 0x00)) ||(ret == 0)
|
||||
)
|
||||
{
|
||||
/* +2008.01 [bj] : added return value */
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.writeSnDIPR(s, addr);
|
||||
W5100.writeSnDPORT(s, port);
|
||||
|
||||
// copy data
|
||||
W5100.send_data_processing(s, (uint8_t *)buf, ret);
|
||||
W5100.execCmdSn(s, Sock_SEND);
|
||||
|
||||
/* +2008.01 bj */
|
||||
while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK )
|
||||
{
|
||||
if (W5100.readSnIR(s) & SnIR::TIMEOUT)
|
||||
{
|
||||
/* +2008.01 [bj]: clear interrupt */
|
||||
W5100.writeSnIR(s, (SnIR::SEND_OK | SnIR::TIMEOUT)); /* clear SEND_OK & TIMEOUT */
|
||||
SPI.endTransaction();
|
||||
return 0;
|
||||
}
|
||||
SPI.endTransaction();
|
||||
yield();
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
}
|
||||
|
||||
/* +2008.01 bj */
|
||||
W5100.writeSnIR(s, SnIR::SEND_OK);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is an application I/F function which is used to receive the data in other then
|
||||
* TCP mode. This function is used to receive UDP, IP_RAW and MAC_RAW mode, and handle the header as well.
|
||||
*
|
||||
* @return This function return received data size for success else -1.
|
||||
*/
|
||||
uint16_t recvfrom(SOCKET s, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port)
|
||||
{
|
||||
uint8_t head[8];
|
||||
uint16_t data_len=0;
|
||||
uint16_t ptr=0;
|
||||
|
||||
if ( len > 0 )
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
ptr = W5100.readSnRX_RD(s);
|
||||
switch (W5100.readSnMR(s) & 0x07)
|
||||
{
|
||||
case SnMR::UDP :
|
||||
W5100.read_data(s, ptr, head, 0x08);
|
||||
ptr += 8;
|
||||
// read peer's IP address, port number.
|
||||
addr[0] = head[0];
|
||||
addr[1] = head[1];
|
||||
addr[2] = head[2];
|
||||
addr[3] = head[3];
|
||||
*port = head[4];
|
||||
*port = (*port << 8) + head[5];
|
||||
data_len = head[6];
|
||||
data_len = (data_len << 8) + head[7];
|
||||
|
||||
W5100.read_data(s, ptr, buf, data_len); // data copy.
|
||||
ptr += data_len;
|
||||
|
||||
W5100.writeSnRX_RD(s, ptr);
|
||||
break;
|
||||
|
||||
case SnMR::IPRAW :
|
||||
W5100.read_data(s, ptr, head, 0x06);
|
||||
ptr += 6;
|
||||
|
||||
addr[0] = head[0];
|
||||
addr[1] = head[1];
|
||||
addr[2] = head[2];
|
||||
addr[3] = head[3];
|
||||
data_len = head[4];
|
||||
data_len = (data_len << 8) + head[5];
|
||||
|
||||
W5100.read_data(s, ptr, buf, data_len); // data copy.
|
||||
ptr += data_len;
|
||||
|
||||
W5100.writeSnRX_RD(s, ptr);
|
||||
break;
|
||||
|
||||
case SnMR::MACRAW:
|
||||
W5100.read_data(s,ptr,head,2);
|
||||
ptr+=2;
|
||||
data_len = head[0];
|
||||
data_len = (data_len<<8) + head[1] - 2;
|
||||
|
||||
W5100.read_data(s,ptr,buf,data_len);
|
||||
ptr += data_len;
|
||||
W5100.writeSnRX_RD(s, ptr);
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
W5100.execCmdSn(s, Sock_RECV);
|
||||
SPI.endTransaction();
|
||||
}
|
||||
return data_len;
|
||||
}
|
||||
|
||||
|
||||
uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len)
|
||||
{
|
||||
uint16_t ret=0;
|
||||
|
||||
if (len > W5100.SSIZE)
|
||||
ret = W5100.SSIZE; // check size not to exceed MAX size.
|
||||
else
|
||||
ret = len;
|
||||
|
||||
if (ret == 0)
|
||||
return 0;
|
||||
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.send_data_processing(s, (uint8_t *)buf, ret);
|
||||
W5100.execCmdSn(s, Sock_SEND);
|
||||
|
||||
while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK )
|
||||
{
|
||||
if (W5100.readSnIR(s) & SnIR::TIMEOUT)
|
||||
{
|
||||
/* in case of igmp, if send fails, then socket closed */
|
||||
/* if you want change, remove this code. */
|
||||
SPI.endTransaction();
|
||||
close(s);
|
||||
return 0;
|
||||
}
|
||||
SPI.endTransaction();
|
||||
yield();
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
}
|
||||
|
||||
W5100.writeSnIR(s, SnIR::SEND_OK);
|
||||
SPI.endTransaction();
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint16_t bufferData(SOCKET s, uint16_t offset, const uint8_t* buf, uint16_t len)
|
||||
{
|
||||
uint16_t ret =0;
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
if (len > W5100.getTXFreeSize(s))
|
||||
{
|
||||
ret = W5100.getTXFreeSize(s); // check size not to exceed MAX size.
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = len;
|
||||
}
|
||||
W5100.send_data_processing_offset(s, offset, buf, ret);
|
||||
SPI.endTransaction();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int startUDP(SOCKET s, uint8_t* addr, uint16_t port)
|
||||
{
|
||||
if
|
||||
(
|
||||
((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) ||
|
||||
((port == 0x00))
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.writeSnDIPR(s, addr);
|
||||
W5100.writeSnDPORT(s, port);
|
||||
SPI.endTransaction();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int sendUDP(SOCKET s)
|
||||
{
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
W5100.execCmdSn(s, Sock_SEND);
|
||||
|
||||
/* +2008.01 bj */
|
||||
while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK )
|
||||
{
|
||||
if (W5100.readSnIR(s) & SnIR::TIMEOUT)
|
||||
{
|
||||
/* +2008.01 [bj]: clear interrupt */
|
||||
W5100.writeSnIR(s, (SnIR::SEND_OK|SnIR::TIMEOUT));
|
||||
SPI.endTransaction();
|
||||
return 0;
|
||||
}
|
||||
SPI.endTransaction();
|
||||
yield();
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
}
|
||||
|
||||
/* +2008.01 bj */
|
||||
W5100.writeSnIR(s, SnIR::SEND_OK);
|
||||
SPI.endTransaction();
|
||||
|
||||
/* Sent ok */
|
||||
return 1;
|
||||
}
|
||||
|
43
Ethernet/utility/socket.h
Normal file
43
Ethernet/utility/socket.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef _SOCKET_H_
|
||||
#define _SOCKET_H_
|
||||
|
||||
#include "w5100.h"
|
||||
|
||||
extern uint8_t socket(SOCKET s, uint8_t protocol, uint16_t port, uint8_t flag); // Opens a socket(TCP or UDP or IP_RAW mode)
|
||||
extern uint8_t socketStatus(SOCKET s);
|
||||
extern void close(SOCKET s); // Close socket
|
||||
extern uint8_t connect(SOCKET s, uint8_t * addr, uint16_t port); // Establish TCP connection (Active connection)
|
||||
extern void disconnect(SOCKET s); // disconnect the connection
|
||||
extern uint8_t listen(SOCKET s); // Establish TCP connection (Passive connection)
|
||||
extern uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len); // Send data (TCP)
|
||||
extern int16_t recv(SOCKET s, uint8_t * buf, int16_t len); // Receive data (TCP)
|
||||
extern int16_t recvAvailable(SOCKET s);
|
||||
extern uint16_t peek(SOCKET s, uint8_t *buf);
|
||||
extern uint16_t sendto(SOCKET s, const uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); // Send data (UDP/IP RAW)
|
||||
extern uint16_t recvfrom(SOCKET s, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); // Receive data (UDP/IP RAW)
|
||||
|
||||
extern uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len);
|
||||
|
||||
// Functions to allow buffered UDP send (i.e. where the UDP datagram is built up over a
|
||||
// number of calls before being sent
|
||||
/*
|
||||
@brief This function sets up a UDP datagram, the data for which will be provided by one
|
||||
or more calls to bufferData and then finally sent with sendUDP.
|
||||
@return 1 if the datagram was successfully set up, or 0 if there was an error
|
||||
*/
|
||||
extern int startUDP(SOCKET s, uint8_t* addr, uint16_t port);
|
||||
/*
|
||||
@brief This function copies up to len bytes of data from buf into a UDP datagram to be
|
||||
sent later by sendUDP. Allows datagrams to be built up from a series of bufferData calls.
|
||||
@return Number of bytes successfully buffered
|
||||
*/
|
||||
uint16_t bufferData(SOCKET s, uint16_t offset, const uint8_t* buf, uint16_t len);
|
||||
/*
|
||||
@brief Send a UDP datagram built up from a sequence of startUDP followed by one or more
|
||||
calls to bufferData.
|
||||
@return 1 if the datagram was successfully sent, or 0 if there was an error
|
||||
*/
|
||||
int sendUDP(SOCKET s);
|
||||
|
||||
#endif
|
||||
/* _SOCKET_H_ */
|
428
Ethernet/utility/w5100.cpp
Normal file
428
Ethernet/utility/w5100.cpp
Normal file
@ -0,0 +1,428 @@
|
||||
/*
|
||||
* Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of either the GNU General Public License version 2
|
||||
* or the GNU Lesser General Public License version 2.1, both as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#if defined(__arm__)
|
||||
#include "SPIFIFO.h"
|
||||
#ifdef HAS_SPIFIFO
|
||||
#define USE_SPIFIFO
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// The W5200 really does require a proper reset pulse!
|
||||
// Its SPI state machine remembers the previously started
|
||||
// burst transfer, even after SS is deasserted. Wiznet's
|
||||
// documentation does not mention this very unfortunate
|
||||
// fact, which means you to really must reset the chip if
|
||||
// it may have ever heard an partial transfer (eg, from a
|
||||
// previous run before clicking Upload in Arduino) or if
|
||||
// its SS and SCK pins are ever left floating.
|
||||
#define W5200_RESET_PIN 9
|
||||
#define W5200_SS_PIN 10
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#include "w5100.h"
|
||||
|
||||
// W5100 controller instance
|
||||
uint16_t W5100Class::SBASE[MAX_SOCK_NUM];
|
||||
uint16_t W5100Class::RBASE[MAX_SOCK_NUM];
|
||||
uint16_t W5100Class::CH_BASE;
|
||||
uint16_t W5100Class::SSIZE;
|
||||
uint16_t W5100Class::SMASK;
|
||||
uint8_t W5100Class::chip;
|
||||
W5100Class W5100;
|
||||
|
||||
|
||||
uint8_t W5100Class::init(void)
|
||||
{
|
||||
uint16_t TXBUF_BASE, RXBUF_BASE;
|
||||
uint8_t i;
|
||||
|
||||
delay(200);
|
||||
//Serial.println("w5100 init");
|
||||
|
||||
#ifdef USE_SPIFIFO
|
||||
SPI.begin();
|
||||
SPIFIFO.begin(W5200_SS_PIN, SPI_CLOCK_12MHz); // W5100 is 14 MHz max
|
||||
#else
|
||||
SPI.begin();
|
||||
SPI.setClockDivider(SPI_CLOCK_DIV2);
|
||||
initSS();
|
||||
#endif
|
||||
|
||||
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
|
||||
if (isW5100()) {
|
||||
CH_BASE = 0x0400;
|
||||
SSIZE = 2048;
|
||||
SMASK = 0x07FF;
|
||||
TXBUF_BASE = 0x4000;
|
||||
RXBUF_BASE = 0x6000;
|
||||
writeTMSR(0x55);
|
||||
writeRMSR(0x55);
|
||||
|
||||
} else if (isW5200()) {
|
||||
CH_BASE = 0x4000;
|
||||
SSIZE = 4096;
|
||||
SMASK = 0x0FFF;
|
||||
TXBUF_BASE = 0x8000;
|
||||
RXBUF_BASE = 0xC000;
|
||||
for (i=0; i<MAX_SOCK_NUM; i++) {
|
||||
writeSnRX_SIZE(i, SSIZE >> 10);
|
||||
writeSnTX_SIZE(i, SSIZE >> 10);
|
||||
}
|
||||
for (; i<8; i++) {
|
||||
writeSnRX_SIZE(i, 0);
|
||||
writeSnTX_SIZE(i, 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
//Serial.println("no chip :-(");
|
||||
chip = 0;
|
||||
SPI.endTransaction();
|
||||
return 0; // no known chip is responding :-(
|
||||
}
|
||||
for (int i=0; i<MAX_SOCK_NUM; i++) {
|
||||
SBASE[i] = TXBUF_BASE + SSIZE * i;
|
||||
RBASE[i] = RXBUF_BASE + SSIZE * i;
|
||||
}
|
||||
SPI.endTransaction();
|
||||
return 1; // successful init
|
||||
}
|
||||
|
||||
void W5100Class::reset(void)
|
||||
{
|
||||
uint16_t count=0;
|
||||
|
||||
//Serial.println("W5100 reset");
|
||||
writeMR(1<<RST);
|
||||
while (++count < 20) {
|
||||
uint8_t mr = readMR();
|
||||
//Serial.print("mr=");
|
||||
//Serial.println(mr, HEX);
|
||||
if (mr == 0) break;
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t W5100Class::isW5100(void)
|
||||
{
|
||||
chip = 51;
|
||||
//Serial.println("W5100 detect W5100 chip");
|
||||
reset();
|
||||
writeMR(0x10);
|
||||
if (readMR() != 0x10) return 0;
|
||||
writeMR(0x12);
|
||||
if (readMR() != 0x12) return 0;
|
||||
writeMR(0x00);
|
||||
if (readMR() != 0x00) return 0;
|
||||
//Serial.println("chip is W5100");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t W5100Class::isW5200(void)
|
||||
{
|
||||
uint8_t mr;
|
||||
chip = 52;
|
||||
//Serial.println("W5100 detect W5200 chip");
|
||||
#ifdef W5200_RESET_PIN
|
||||
pinMode(W5200_RESET_PIN, OUTPUT);
|
||||
digitalWrite(W5200_RESET_PIN, LOW);
|
||||
delay(1);
|
||||
digitalWrite(W5200_RESET_PIN, HIGH);
|
||||
delay(150);
|
||||
#endif
|
||||
reset();
|
||||
writeMR(0x08);
|
||||
mr = readMR();
|
||||
//Serial.print("mr=");
|
||||
//Serial.println(mr, HEX);
|
||||
if (mr != 0x08) return 0;
|
||||
writeMR(0x10);
|
||||
mr = readMR();
|
||||
//Serial.print("mr=");
|
||||
//Serial.println(mr, HEX);
|
||||
if (mr != 0x10) return 0;
|
||||
writeMR(0x00);
|
||||
mr = readMR();
|
||||
//Serial.print("mr=");
|
||||
//Serial.println(mr, HEX);
|
||||
if (mr != 0x00) return 0;
|
||||
//Serial.println("chip is W5200");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t W5100Class::getTXFreeSize(SOCKET s)
|
||||
{
|
||||
uint16_t val=0, val1=0;
|
||||
do {
|
||||
val1 = readSnTX_FSR(s);
|
||||
if (val1 != 0)
|
||||
val = readSnTX_FSR(s);
|
||||
}
|
||||
while (val != val1);
|
||||
return val;
|
||||
}
|
||||
|
||||
uint16_t W5100Class::getRXReceivedSize(SOCKET s)
|
||||
{
|
||||
uint16_t val=0,val1=0;
|
||||
do {
|
||||
val1 = readSnRX_RSR(s);
|
||||
if (val1 != 0)
|
||||
val = readSnRX_RSR(s);
|
||||
}
|
||||
while (val != val1);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
void W5100Class::send_data_processing(SOCKET s, const uint8_t *data, uint16_t len)
|
||||
{
|
||||
// This is same as having no offset in a call to send_data_processing_offset
|
||||
send_data_processing_offset(s, 0, data, len);
|
||||
}
|
||||
|
||||
void W5100Class::send_data_processing_offset(SOCKET s, uint16_t data_offset, const uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint16_t ptr = readSnTX_WR(s);
|
||||
ptr += data_offset;
|
||||
uint16_t offset = ptr & SMASK;
|
||||
uint16_t dstAddr = offset + SBASE[s];
|
||||
|
||||
if (offset + len > SSIZE)
|
||||
{
|
||||
// Wrap around circular buffer
|
||||
uint16_t size = SSIZE - offset;
|
||||
write(dstAddr, data, size);
|
||||
write(SBASE[s], data + size, len - size);
|
||||
}
|
||||
else {
|
||||
write(dstAddr, data, len);
|
||||
}
|
||||
|
||||
ptr += len;
|
||||
writeSnTX_WR(s, ptr);
|
||||
}
|
||||
|
||||
|
||||
void W5100Class::recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uint8_t peek)
|
||||
{
|
||||
uint16_t ptr;
|
||||
ptr = readSnRX_RD(s);
|
||||
read_data(s, ptr, data, len);
|
||||
if (!peek)
|
||||
{
|
||||
ptr += len;
|
||||
writeSnRX_RD(s, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void W5100Class::read_data(SOCKET s, uint16_t src, volatile uint8_t *dst, uint16_t len)
|
||||
{
|
||||
uint16_t size;
|
||||
uint16_t src_mask;
|
||||
uint16_t src_ptr;
|
||||
|
||||
src_mask = (uint16_t)src & SMASK;
|
||||
src_ptr = RBASE[s] + src_mask;
|
||||
|
||||
if( (src_mask + len) > SSIZE )
|
||||
{
|
||||
size = SSIZE - src_mask;
|
||||
read(src_ptr, (uint8_t *)dst, size);
|
||||
dst += size;
|
||||
read(RBASE[s], (uint8_t *) dst, len - size);
|
||||
}
|
||||
else
|
||||
read(src_ptr, (uint8_t *) dst, len);
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_SPIFIFO
|
||||
uint16_t W5100Class::write(uint16_t addr, const uint8_t *buf, uint16_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
if (chip == 51) {
|
||||
for (i=0; i<len; i++) {
|
||||
SPIFIFO.write16(0xF000 | (addr >> 8), SPI_CONTINUE);
|
||||
SPIFIFO.write16((addr << 8) | buf[i]);
|
||||
addr++;
|
||||
SPIFIFO.read();
|
||||
SPIFIFO.read();
|
||||
}
|
||||
} else {
|
||||
SPIFIFO.clear();
|
||||
SPIFIFO.write16(addr, SPI_CONTINUE);
|
||||
SPIFIFO.write16(len | 0x8000, SPI_CONTINUE);
|
||||
for (i=0; i<len; i++) {
|
||||
SPIFIFO.write(buf[i], ((i+1<len) ? SPI_CONTINUE : 0));
|
||||
SPIFIFO.read();
|
||||
}
|
||||
SPIFIFO.read();
|
||||
SPIFIFO.read();
|
||||
}
|
||||
return len;
|
||||
}
|
||||
#else
|
||||
uint16_t W5100Class::write(uint16_t addr, const uint8_t *buf, uint16_t len)
|
||||
{
|
||||
if (chip == 51) {
|
||||
for (uint16_t i=0; i<len; i++) {
|
||||
setSS();
|
||||
SPI.transfer(0xF0);
|
||||
SPI.transfer(addr >> 8);
|
||||
SPI.transfer(addr & 0xFF);
|
||||
addr++;
|
||||
SPI.transfer(buf[i]);
|
||||
resetSS();
|
||||
}
|
||||
} else {
|
||||
setSS();
|
||||
SPI.transfer(addr >> 8);
|
||||
SPI.transfer(addr & 0xFF);
|
||||
SPI.transfer(((len >> 8) & 0x7F) | 0x80);
|
||||
SPI.transfer(len & 0xFF);
|
||||
for (uint16_t i=0; i<len; i++) {
|
||||
SPI.transfer(buf[i]);
|
||||
}
|
||||
resetSS();
|
||||
}
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_SPIFIFO
|
||||
uint16_t W5100Class::read(uint16_t addr, uint8_t *buf, uint16_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
if (chip == 51) {
|
||||
for (i=0; i<len; i++) {
|
||||
#if 1
|
||||
SPIFIFO.write(0x0F, SPI_CONTINUE);
|
||||
SPIFIFO.write16(addr, SPI_CONTINUE);
|
||||
addr++;
|
||||
SPIFIFO.read();
|
||||
SPIFIFO.write(0);
|
||||
SPIFIFO.read();
|
||||
buf[i] = SPIFIFO.read();
|
||||
#endif
|
||||
#if 0
|
||||
// this does not work, but why?
|
||||
SPIFIFO.write16(0x0F00 | (addr >> 8), SPI_CONTINUE);
|
||||
SPIFIFO.write16(addr << 8);
|
||||
addr++;
|
||||
SPIFIFO.read();
|
||||
buf[i] = SPIFIFO.read();
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
// len = 1: write header, write 1 byte, read
|
||||
// len = 2: write header, write 2 byte, read
|
||||
// len = 3,5,7
|
||||
SPIFIFO.clear();
|
||||
SPIFIFO.write16(addr, SPI_CONTINUE);
|
||||
SPIFIFO.write16(len & 0x7FFF, SPI_CONTINUE);
|
||||
SPIFIFO.read();
|
||||
if (len == 1) {
|
||||
// read only 1 byte
|
||||
SPIFIFO.write(0);
|
||||
SPIFIFO.read();
|
||||
*buf = SPIFIFO.read();
|
||||
} else if (len == 2) {
|
||||
// read only 2 bytes
|
||||
SPIFIFO.write16(0);
|
||||
SPIFIFO.read();
|
||||
uint32_t val = SPIFIFO.read();
|
||||
*buf++ = val >> 8;
|
||||
*buf = val;
|
||||
} else if ((len & 1)) {
|
||||
// read 3 or more, odd length
|
||||
//Serial.print("W5200 read, len=");
|
||||
//Serial.println(len);
|
||||
uint32_t count = len / 2;
|
||||
SPIFIFO.write16(0, SPI_CONTINUE);
|
||||
SPIFIFO.read();
|
||||
do {
|
||||
if (count > 1) SPIFIFO.write16(0, SPI_CONTINUE);
|
||||
else SPIFIFO.write(0);
|
||||
uint32_t val = SPIFIFO.read();
|
||||
//TODO: WebClient_speedtest with READSIZE 7 is
|
||||
//dramatically faster with this Serial.print(),
|
||||
//and the 2 above, but not without both. Why?!
|
||||
//Serial.println(val, HEX);
|
||||
*buf++ = val >> 8;
|
||||
*buf++ = val;
|
||||
} while (--count > 0);
|
||||
*buf = SPIFIFO.read();
|
||||
//Serial.println(*buf, HEX);
|
||||
} else {
|
||||
// read 4 or more, odd length
|
||||
//Serial.print("W5200 read, len=");
|
||||
//Serial.println(len);
|
||||
uint32_t count = len / 2 - 1;
|
||||
SPIFIFO.write16(0, SPI_CONTINUE);
|
||||
SPIFIFO.read();
|
||||
do {
|
||||
SPIFIFO.write16(0, (count > 0) ? SPI_CONTINUE : 0);
|
||||
uint32_t val = SPIFIFO.read();
|
||||
*buf++ = val >> 8;
|
||||
*buf++ = val;
|
||||
} while (--count > 0);
|
||||
uint32_t val = SPIFIFO.read();
|
||||
*buf++ = val >> 8;
|
||||
*buf++ = val;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
#else
|
||||
uint16_t W5100Class::read(uint16_t addr, uint8_t *buf, uint16_t len)
|
||||
{
|
||||
if (chip == 51) {
|
||||
for (uint16_t i=0; i<len; i++) {
|
||||
setSS();
|
||||
SPI.transfer(0x0F);
|
||||
SPI.transfer(addr >> 8);
|
||||
SPI.transfer(addr & 0xFF);
|
||||
addr++;
|
||||
buf[i] = SPI.transfer(0);
|
||||
resetSS();
|
||||
}
|
||||
} else {
|
||||
setSS();
|
||||
SPI.transfer(addr >> 8);
|
||||
SPI.transfer(addr & 0xFF);
|
||||
SPI.transfer((len >> 8) & 0x7F);
|
||||
SPI.transfer(len & 0xFF);
|
||||
for (uint16_t i=0; i<len; i++) {
|
||||
buf[i] = SPI.transfer(0);
|
||||
}
|
||||
resetSS();
|
||||
}
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
|
||||
void W5100Class::execCmdSn(SOCKET s, SockCMD _cmd) {
|
||||
// Send command to socket
|
||||
writeSnCR(s, _cmd);
|
||||
// Wait for command to complete
|
||||
while (readSnCR(s))
|
||||
;
|
||||
}
|
340
Ethernet/utility/w5100.h
Normal file
340
Ethernet/utility/w5100.h
Normal file
@ -0,0 +1,340 @@
|
||||
/*
|
||||
* Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of either the GNU General Public License version 2
|
||||
* or the GNU Lesser General Public License version 2.1, both as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef W5100_H_INCLUDED
|
||||
#define W5100_H_INCLUDED
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0)
|
||||
//#define SPI_ETHERNET_SETTINGS SPISettings(8000000, MSBFIRST, SPI_MODE0)
|
||||
//#define SPI_ETHERNET_SETTINGS SPISettings(4000000, MSBFIRST, SPI_MODE0)
|
||||
|
||||
#define MAX_SOCK_NUM 4
|
||||
|
||||
typedef uint8_t SOCKET;
|
||||
|
||||
class SnMR {
|
||||
public:
|
||||
static const uint8_t CLOSE = 0x00;
|
||||
static const uint8_t TCP = 0x01;
|
||||
static const uint8_t UDP = 0x02;
|
||||
static const uint8_t IPRAW = 0x03;
|
||||
static const uint8_t MACRAW = 0x04;
|
||||
static const uint8_t PPPOE = 0x05;
|
||||
static const uint8_t ND = 0x20;
|
||||
static const uint8_t MULTI = 0x80;
|
||||
};
|
||||
|
||||
enum SockCMD {
|
||||
Sock_OPEN = 0x01,
|
||||
Sock_LISTEN = 0x02,
|
||||
Sock_CONNECT = 0x04,
|
||||
Sock_DISCON = 0x08,
|
||||
Sock_CLOSE = 0x10,
|
||||
Sock_SEND = 0x20,
|
||||
Sock_SEND_MAC = 0x21,
|
||||
Sock_SEND_KEEP = 0x22,
|
||||
Sock_RECV = 0x40
|
||||
};
|
||||
|
||||
class SnIR {
|
||||
public:
|
||||
static const uint8_t SEND_OK = 0x10;
|
||||
static const uint8_t TIMEOUT = 0x08;
|
||||
static const uint8_t RECV = 0x04;
|
||||
static const uint8_t DISCON = 0x02;
|
||||
static const uint8_t CON = 0x01;
|
||||
};
|
||||
|
||||
class SnSR {
|
||||
public:
|
||||
static const uint8_t CLOSED = 0x00;
|
||||
static const uint8_t INIT = 0x13;
|
||||
static const uint8_t LISTEN = 0x14;
|
||||
static const uint8_t SYNSENT = 0x15;
|
||||
static const uint8_t SYNRECV = 0x16;
|
||||
static const uint8_t ESTABLISHED = 0x17;
|
||||
static const uint8_t FIN_WAIT = 0x18;
|
||||
static const uint8_t CLOSING = 0x1A;
|
||||
static const uint8_t TIME_WAIT = 0x1B;
|
||||
static const uint8_t CLOSE_WAIT = 0x1C;
|
||||
static const uint8_t LAST_ACK = 0x1D;
|
||||
static const uint8_t UDP = 0x22;
|
||||
static const uint8_t IPRAW = 0x32;
|
||||
static const uint8_t MACRAW = 0x42;
|
||||
static const uint8_t PPPOE = 0x5F;
|
||||
};
|
||||
|
||||
class IPPROTO {
|
||||
public:
|
||||
static const uint8_t IP = 0;
|
||||
static const uint8_t ICMP = 1;
|
||||
static const uint8_t IGMP = 2;
|
||||
static const uint8_t GGP = 3;
|
||||
static const uint8_t TCP = 6;
|
||||
static const uint8_t PUP = 12;
|
||||
static const uint8_t UDP = 17;
|
||||
static const uint8_t IDP = 22;
|
||||
static const uint8_t ND = 77;
|
||||
static const uint8_t RAW = 255;
|
||||
};
|
||||
|
||||
class W5100Class {
|
||||
|
||||
public:
|
||||
static uint8_t init(void);
|
||||
|
||||
/**
|
||||
* @brief This function is being used for copy the data form Receive buffer of the chip to application buffer.
|
||||
*
|
||||
* It calculate the actual physical address where one has to read
|
||||
* the data from Receive buffer. Here also take care of the condition while it exceed
|
||||
* the Rx memory uper-bound of socket.
|
||||
*/
|
||||
static void read_data(SOCKET s, uint16_t src, volatile uint8_t * dst, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief This function is being called by send() and sendto() function also.
|
||||
*
|
||||
* This function read the Tx write pointer register and after copy the data in buffer update the Tx write pointer
|
||||
* register. User should read upper byte first and lower byte later to get proper value.
|
||||
*/
|
||||
static void send_data_processing(SOCKET s, const uint8_t *data, uint16_t len);
|
||||
/**
|
||||
* @brief A copy of send_data_processing that uses the provided ptr for the
|
||||
* write offset. Only needed for the "streaming" UDP API, where
|
||||
* a single UDP packet is built up over a number of calls to
|
||||
* send_data_processing_ptr, because TX_WR doesn't seem to get updated
|
||||
* correctly in those scenarios
|
||||
* @param ptr value to use in place of TX_WR. If 0, then the value is read
|
||||
* in from TX_WR
|
||||
* @return New value for ptr, to be used in the next call
|
||||
*/
|
||||
// FIXME Update documentation
|
||||
static void send_data_processing_offset(SOCKET s, uint16_t data_offset, const uint8_t *data, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief This function is being called by recv() also.
|
||||
*
|
||||
* This function read the Rx read pointer register
|
||||
* and after copy the data from receive buffer update the Rx write pointer register.
|
||||
* User should read upper byte first and lower byte later to get proper value.
|
||||
*/
|
||||
static void recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uint8_t peek = 0);
|
||||
|
||||
inline void setGatewayIp(uint8_t * addr) { writeGAR(addr); }
|
||||
inline void getGatewayIp(uint8_t * addr) { readGAR(addr); }
|
||||
|
||||
inline void setSubnetMask(uint8_t * addr) { writeSUBR(addr); }
|
||||
inline void getSubnetMask(uint8_t * addr) { readSUBR(addr); }
|
||||
|
||||
inline void setMACAddress(uint8_t * addr) { writeSHAR(addr); }
|
||||
inline void getMACAddress(uint8_t * addr) { readSHAR(addr); }
|
||||
|
||||
inline void setIPAddress(uint8_t * addr) { writeSIPR(addr); }
|
||||
inline void getIPAddress(uint8_t * addr) { readSIPR(addr); }
|
||||
|
||||
inline void setRetransmissionTime(uint16_t timeout) { writeRTR(timeout); }
|
||||
inline void setRetransmissionCount(uint8_t retry) { writeRCR(retry); }
|
||||
|
||||
static void execCmdSn(SOCKET s, SockCMD _cmd);
|
||||
|
||||
static uint16_t getTXFreeSize(SOCKET s);
|
||||
static uint16_t getRXReceivedSize(SOCKET s);
|
||||
|
||||
|
||||
// W5100 Registers
|
||||
// ---------------
|
||||
private:
|
||||
static uint16_t write(uint16_t addr, const uint8_t *buf, uint16_t len);
|
||||
static uint8_t write(uint16_t addr, uint8_t data) {
|
||||
return write(addr, &data, 1);
|
||||
}
|
||||
static uint16_t read(uint16_t addr, uint8_t *buf, uint16_t len);
|
||||
static uint8_t read(uint16_t addr) {
|
||||
uint8_t data;
|
||||
read(addr, &data, 1);
|
||||
return data;
|
||||
}
|
||||
|
||||
#define __GP_REGISTER8(name, address) \
|
||||
static inline void write##name(uint8_t _data) { \
|
||||
write(address, _data); \
|
||||
} \
|
||||
static inline uint8_t read##name() { \
|
||||
return read(address); \
|
||||
}
|
||||
#define __GP_REGISTER16(name, address) \
|
||||
static void write##name(uint16_t _data) { \
|
||||
uint8_t buf[2]; \
|
||||
buf[0] = _data >> 8; \
|
||||
buf[1] = _data & 0xFF; \
|
||||
write(address, buf, 2); \
|
||||
} \
|
||||
static uint16_t read##name() { \
|
||||
uint8_t buf[2]; \
|
||||
read(address, buf, 2); \
|
||||
return (buf[0] << 8) | buf[1]; \
|
||||
}
|
||||
#define __GP_REGISTER_N(name, address, size) \
|
||||
static uint16_t write##name(uint8_t *_buff) { \
|
||||
return write(address, _buff, size); \
|
||||
} \
|
||||
static uint16_t read##name(uint8_t *_buff) { \
|
||||
return read(address, _buff, size); \
|
||||
}
|
||||
|
||||
public:
|
||||
__GP_REGISTER8 (MR, 0x0000); // Mode
|
||||
__GP_REGISTER_N(GAR, 0x0001, 4); // Gateway IP address
|
||||
__GP_REGISTER_N(SUBR, 0x0005, 4); // Subnet mask address
|
||||
__GP_REGISTER_N(SHAR, 0x0009, 6); // Source MAC address
|
||||
__GP_REGISTER_N(SIPR, 0x000F, 4); // Source IP address
|
||||
__GP_REGISTER8 (IR, 0x0015); // Interrupt
|
||||
__GP_REGISTER8 (IMR, 0x0016); // Interrupt Mask
|
||||
__GP_REGISTER16(RTR, 0x0017); // Timeout address
|
||||
__GP_REGISTER8 (RCR, 0x0019); // Retry count
|
||||
__GP_REGISTER8 (RMSR, 0x001A); // Receive memory size (W5100 only)
|
||||
__GP_REGISTER8 (TMSR, 0x001B); // Transmit memory size (W5100 only)
|
||||
__GP_REGISTER8 (PATR, 0x001C); // Authentication type address in PPPoE mode
|
||||
__GP_REGISTER8 (PTIMER, 0x0028); // PPP LCP Request Timer
|
||||
__GP_REGISTER8 (PMAGIC, 0x0029); // PPP LCP Magic Number
|
||||
__GP_REGISTER_N(UIPR, 0x002A, 4); // Unreachable IP address in UDP mode (W5100 only)
|
||||
__GP_REGISTER16(UPORT, 0x002E); // Unreachable Port address in UDP mode (W5100 only)
|
||||
|
||||
#undef __GP_REGISTER8
|
||||
#undef __GP_REGISTER16
|
||||
#undef __GP_REGISTER_N
|
||||
|
||||
// W5100 Socket registers
|
||||
// ----------------------
|
||||
private:
|
||||
static inline uint8_t readSn(SOCKET s, uint16_t addr) {
|
||||
return read(CH_BASE + s * CH_SIZE + addr);
|
||||
}
|
||||
static inline uint8_t writeSn(SOCKET s, uint16_t addr, uint8_t data) {
|
||||
return write(CH_BASE + s * CH_SIZE + addr, data);
|
||||
}
|
||||
static inline uint16_t readSn(SOCKET s, uint16_t addr, uint8_t *buf, uint16_t len) {
|
||||
return read(CH_BASE + s * CH_SIZE + addr, buf, len);
|
||||
}
|
||||
static inline uint16_t writeSn(SOCKET s, uint16_t addr, uint8_t *buf, uint16_t len) {
|
||||
return write(CH_BASE + s * CH_SIZE + addr, buf, len);
|
||||
}
|
||||
|
||||
static uint16_t CH_BASE;
|
||||
static const uint16_t CH_SIZE = 0x0100;
|
||||
|
||||
#define __SOCKET_REGISTER8(name, address) \
|
||||
static inline void write##name(SOCKET _s, uint8_t _data) { \
|
||||
writeSn(_s, address, _data); \
|
||||
} \
|
||||
static inline uint8_t read##name(SOCKET _s) { \
|
||||
return readSn(_s, address); \
|
||||
}
|
||||
#define __SOCKET_REGISTER16(name, address) \
|
||||
static void write##name(SOCKET _s, uint16_t _data) { \
|
||||
uint8_t buf[2]; \
|
||||
buf[0] = _data >> 8; \
|
||||
buf[1] = _data & 0xFF; \
|
||||
writeSn(_s, address, buf, 2); \
|
||||
} \
|
||||
static uint16_t read##name(SOCKET _s) { \
|
||||
uint8_t buf[2]; \
|
||||
readSn(_s, address, buf, 2); \
|
||||
return (buf[0] << 8) | buf[1]; \
|
||||
}
|
||||
#define __SOCKET_REGISTER_N(name, address, size) \
|
||||
static uint16_t write##name(SOCKET _s, uint8_t *_buff) { \
|
||||
return writeSn(_s, address, _buff, size); \
|
||||
} \
|
||||
static uint16_t read##name(SOCKET _s, uint8_t *_buff) { \
|
||||
return readSn(_s, address, _buff, size); \
|
||||
}
|
||||
|
||||
public:
|
||||
__SOCKET_REGISTER8(SnMR, 0x0000) // Mode
|
||||
__SOCKET_REGISTER8(SnCR, 0x0001) // Command
|
||||
__SOCKET_REGISTER8(SnIR, 0x0002) // Interrupt
|
||||
__SOCKET_REGISTER8(SnSR, 0x0003) // Status
|
||||
__SOCKET_REGISTER16(SnPORT, 0x0004) // Source Port
|
||||
__SOCKET_REGISTER_N(SnDHAR, 0x0006, 6) // Destination Hardw Addr
|
||||
__SOCKET_REGISTER_N(SnDIPR, 0x000C, 4) // Destination IP Addr
|
||||
__SOCKET_REGISTER16(SnDPORT, 0x0010) // Destination Port
|
||||
__SOCKET_REGISTER16(SnMSSR, 0x0012) // Max Segment Size
|
||||
__SOCKET_REGISTER8(SnPROTO, 0x0014) // Protocol in IP RAW Mode
|
||||
__SOCKET_REGISTER8(SnTOS, 0x0015) // IP TOS
|
||||
__SOCKET_REGISTER8(SnTTL, 0x0016) // IP TTL
|
||||
__SOCKET_REGISTER8(SnRX_SIZE, 0x001E) // RX Memory Size (W5200 only)
|
||||
__SOCKET_REGISTER8(SnTX_SIZE, 0x001F) // RX Memory Size (W5200 only)
|
||||
__SOCKET_REGISTER16(SnTX_FSR, 0x0020) // TX Free Size
|
||||
__SOCKET_REGISTER16(SnTX_RD, 0x0022) // TX Read Pointer
|
||||
__SOCKET_REGISTER16(SnTX_WR, 0x0024) // TX Write Pointer
|
||||
__SOCKET_REGISTER16(SnRX_RSR, 0x0026) // RX Free Size
|
||||
__SOCKET_REGISTER16(SnRX_RD, 0x0028) // RX Read Pointer
|
||||
__SOCKET_REGISTER16(SnRX_WR, 0x002A) // RX Write Pointer (supported?)
|
||||
|
||||
#undef __SOCKET_REGISTER8
|
||||
#undef __SOCKET_REGISTER16
|
||||
#undef __SOCKET_REGISTER_N
|
||||
|
||||
|
||||
private:
|
||||
static uint8_t chip;
|
||||
static void reset(void);
|
||||
static uint8_t isW5100(void);
|
||||
static uint8_t isW5200(void);
|
||||
|
||||
static const uint8_t RST = 7; // Reset BIT
|
||||
|
||||
static const int SOCKETS = 4;
|
||||
static uint16_t SMASK;
|
||||
public:
|
||||
static uint16_t SSIZE;
|
||||
private:
|
||||
//receive and transmit have same buffer sizes
|
||||
static uint16_t SBASE[SOCKETS]; // Tx buffer base address
|
||||
static uint16_t RBASE[SOCKETS]; // Rx buffer base address
|
||||
|
||||
private:
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
inline static void initSS() { DDRB |= _BV(4); };
|
||||
inline static void setSS() { PORTB &= ~_BV(4); };
|
||||
inline static void resetSS() { PORTB |= _BV(4); };
|
||||
#elif defined(__AVR_ATmega32U4__) && defined(CORE_TEENSY)
|
||||
inline static void initSS() { DDRB |= _BV(0); };
|
||||
inline static void setSS() { PORTB &= ~_BV(0); };
|
||||
inline static void resetSS() { PORTB |= _BV(0); };
|
||||
#elif defined(__AVR_ATmega32U4__)
|
||||
inline static void initSS() { DDRB |= _BV(6); };
|
||||
inline static void setSS() { PORTB &= ~_BV(6); };
|
||||
inline static void resetSS() { PORTB |= _BV(6); };
|
||||
#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)
|
||||
inline static void initSS() { DDRB |= _BV(0); };
|
||||
inline static void setSS() { PORTB &= ~_BV(0); };
|
||||
inline static void resetSS() { PORTB |= _BV(0); };
|
||||
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
|
||||
inline static void initSS() { pinMode(10, OUTPUT); };
|
||||
inline static void setSS() { digitalWriteFast(10, LOW); };
|
||||
inline static void resetSS() { digitalWriteFast(10, HIGH); };
|
||||
#else
|
||||
inline static void initSS() { DDRB |= _BV(2); };
|
||||
inline static void setSS() { PORTB &= ~_BV(2); };
|
||||
inline static void resetSS() { PORTB |= _BV(2); };
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
extern W5100Class W5100;
|
||||
|
||||
|
||||
|
||||
#endif
|
634
SPI/SPI.cpp
Normal file
634
SPI/SPI.cpp
Normal file
@ -0,0 +1,634 @@
|
||||
/*
|
||||
* Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
|
||||
* SPI Master library for arduino.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of either the GNU General Public License version 2
|
||||
* or the GNU Lesser General Public License version 2.1, both as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include "SPI.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
/* 8 bit AVR-based boards */
|
||||
/**********************************************************/
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
SPIClass SPI;
|
||||
|
||||
uint8_t SPIClass::interruptMode = 0;
|
||||
uint8_t SPIClass::interruptMask = 0;
|
||||
uint8_t SPIClass::interruptSave = 0;
|
||||
#ifdef SPI_TRANSACTION_MISMATCH_LED
|
||||
uint8_t SPIClass::inTransactionFlag = 0;
|
||||
#endif
|
||||
|
||||
void SPIClass::begin()
|
||||
{
|
||||
// Set SS to high so a connected chip will be "deselected" by default
|
||||
digitalWrite(SS, HIGH);
|
||||
|
||||
// When the SS pin is set as OUTPUT, it can be used as
|
||||
// a general purpose output port (it doesn't influence
|
||||
// SPI operations).
|
||||
pinMode(SS, OUTPUT);
|
||||
|
||||
// Warning: if the SS pin ever becomes a LOW INPUT then SPI
|
||||
// automatically switches to Slave, so the data direction of
|
||||
// the SS pin MUST be kept as OUTPUT.
|
||||
SPCR |= _BV(MSTR);
|
||||
SPCR |= _BV(SPE);
|
||||
|
||||
// Set direction register for SCK and MOSI pin.
|
||||
// MISO pin automatically overrides to INPUT.
|
||||
// By doing this AFTER enabling SPI, we avoid accidentally
|
||||
// clocking in a single bit since the lines go directly
|
||||
// from "input" to SPI control.
|
||||
// http://code.google.com/p/arduino/issues/detail?id=888
|
||||
pinMode(SCK, OUTPUT);
|
||||
pinMode(MOSI, OUTPUT);
|
||||
}
|
||||
|
||||
void SPIClass::end() {
|
||||
SPCR &= ~_BV(SPE);
|
||||
}
|
||||
|
||||
// mapping of interrupt numbers to bits within SPI_AVR_EIMSK
|
||||
#if defined(__AVR_ATmega32U4__)
|
||||
#define SPI_INT0_MASK (1<<INT0)
|
||||
#define SPI_INT1_MASK (1<<INT1)
|
||||
#define SPI_INT2_MASK (1<<INT2)
|
||||
#define SPI_INT3_MASK (1<<INT3)
|
||||
#define SPI_INT4_MASK (1<<INT6)
|
||||
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
||||
#define SPI_INT0_MASK (1<<INT0)
|
||||
#define SPI_INT1_MASK (1<<INT1)
|
||||
#define SPI_INT2_MASK (1<<INT2)
|
||||
#define SPI_INT3_MASK (1<<INT3)
|
||||
#define SPI_INT4_MASK (1<<INT4)
|
||||
#define SPI_INT5_MASK (1<<INT5)
|
||||
#define SPI_INT6_MASK (1<<INT6)
|
||||
#define SPI_INT7_MASK (1<<INT7)
|
||||
#elif defined(EICRA) && defined(EICRB) && defined(EIMSK)
|
||||
#define SPI_INT0_MASK (1<<INT4)
|
||||
#define SPI_INT1_MASK (1<<INT5)
|
||||
#define SPI_INT2_MASK (1<<INT0)
|
||||
#define SPI_INT3_MASK (1<<INT1)
|
||||
#define SPI_INT4_MASK (1<<INT2)
|
||||
#define SPI_INT5_MASK (1<<INT3)
|
||||
#define SPI_INT6_MASK (1<<INT6)
|
||||
#define SPI_INT7_MASK (1<<INT7)
|
||||
#else
|
||||
#ifdef INT0
|
||||
#define SPI_INT0_MASK (1<<INT0)
|
||||
#endif
|
||||
#ifdef INT1
|
||||
#define SPI_INT1_MASK (1<<INT1)
|
||||
#endif
|
||||
#ifdef INT2
|
||||
#define SPI_INT2_MASK (1<<INT2)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void SPIClass::usingInterrupt(uint8_t interruptNumber)
|
||||
{
|
||||
uint8_t stmp, mask;
|
||||
|
||||
if (interruptMode > 1) return;
|
||||
|
||||
stmp = SREG;
|
||||
noInterrupts();
|
||||
switch (interruptNumber) {
|
||||
#ifdef SPI_INT0_MASK
|
||||
case 0: mask = SPI_INT0_MASK; break;
|
||||
#endif
|
||||
#ifdef SPI_INT1_MASK
|
||||
case 1: mask = SPI_INT1_MASK; break;
|
||||
#endif
|
||||
#ifdef SPI_INT2_MASK
|
||||
case 2: mask = SPI_INT2_MASK; break;
|
||||
#endif
|
||||
#ifdef SPI_INT3_MASK
|
||||
case 3: mask = SPI_INT3_MASK; break;
|
||||
#endif
|
||||
#ifdef SPI_INT4_MASK
|
||||
case 4: mask = SPI_INT4_MASK; break;
|
||||
#endif
|
||||
#ifdef SPI_INT5_MASK
|
||||
case 5: mask = SPI_INT5_MASK; break;
|
||||
#endif
|
||||
#ifdef SPI_INT6_MASK
|
||||
case 6: mask = SPI_INT6_MASK; break;
|
||||
#endif
|
||||
#ifdef SPI_INT7_MASK
|
||||
case 7: mask = SPI_INT7_MASK; break;
|
||||
#endif
|
||||
default:
|
||||
interruptMode = 2;
|
||||
SREG = stmp;
|
||||
return;
|
||||
}
|
||||
interruptMode = 1;
|
||||
interruptMask |= mask;
|
||||
SREG = stmp;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
/* 32 bit Teensy 3.0 and 3.1 */
|
||||
/**********************************************************/
|
||||
|
||||
#elif defined(__arm__) && defined(TEENSYDUINO) && defined(KINETISK)
|
||||
|
||||
SPIClass SPI;
|
||||
|
||||
uint8_t SPIClass::interruptMasksUsed = 0;
|
||||
uint32_t SPIClass::interruptMask[(NVIC_NUM_INTERRUPTS+31)/32];
|
||||
uint32_t SPIClass::interruptSave[(NVIC_NUM_INTERRUPTS+31)/32];
|
||||
#ifdef SPI_TRANSACTION_MISMATCH_LED
|
||||
uint8_t SPIClass::inTransactionFlag = 0;
|
||||
#endif
|
||||
|
||||
void SPIClass::begin()
|
||||
{
|
||||
SIM_SCGC6 |= SIM_SCGC6_SPI0;
|
||||
SPI0_MCR = SPI_MCR_MDIS | SPI_MCR_HALT | SPI_MCR_PCSIS(0x1F);
|
||||
SPI0_CTAR0 = SPI_CTAR_FMSZ(7) | SPI_CTAR_PBR(0) | SPI_CTAR_BR(1) | SPI_CTAR_CSSCK(1);
|
||||
SPI0_CTAR1 = SPI_CTAR_FMSZ(15) | SPI_CTAR_PBR(0) | SPI_CTAR_BR(1) | SPI_CTAR_CSSCK(1);
|
||||
SPI0_MCR = SPI_MCR_MSTR | SPI_MCR_PCSIS(0x1F);
|
||||
SPCR.enable_pins(); // pins managed by SPCRemulation in avr_emulation.h
|
||||
}
|
||||
|
||||
void SPIClass::end() {
|
||||
SPCR.disable_pins();
|
||||
SPI0_MCR = SPI_MCR_MDIS | SPI_MCR_HALT | SPI_MCR_PCSIS(0x1F);
|
||||
}
|
||||
|
||||
void SPIClass::usingInterrupt(IRQ_NUMBER_t interruptName)
|
||||
{
|
||||
uint32_t n = (uint32_t)interruptName;
|
||||
|
||||
if (n >= NVIC_NUM_INTERRUPTS) return;
|
||||
|
||||
//Serial.print("usingInterrupt ");
|
||||
//Serial.println(n);
|
||||
interruptMasksUsed |= (1 << (n >> 5));
|
||||
interruptMask[n >> 5] |= (1 << (n & 0x1F));
|
||||
//Serial.printf("interruptMasksUsed = %d\n", interruptMasksUsed);
|
||||
//Serial.printf("interruptMask[0] = %08X\n", interruptMask[0]);
|
||||
//Serial.printf("interruptMask[1] = %08X\n", interruptMask[1]);
|
||||
//Serial.printf("interruptMask[2] = %08X\n", interruptMask[2]);
|
||||
}
|
||||
|
||||
void SPIClass::notUsingInterrupt(IRQ_NUMBER_t interruptName)
|
||||
{
|
||||
uint32_t n = (uint32_t)interruptName;
|
||||
if (n >= NVIC_NUM_INTERRUPTS) return;
|
||||
interruptMask[n >> 5] &= ~(1 << (n & 0x1F));
|
||||
if (interruptMask[n >> 5] == 0) {
|
||||
interruptMasksUsed &= ~(1 << (n >> 5));
|
||||
}
|
||||
}
|
||||
|
||||
const uint16_t SPISettings::ctar_div_table[23] = {
|
||||
2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32, 40,
|
||||
56, 64, 96, 128, 192, 256, 384, 512, 640, 768
|
||||
};
|
||||
const uint32_t SPISettings::ctar_clock_table[23] = {
|
||||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(0) | SPI_CTAR_DBR | SPI_CTAR_CSSCK(0),
|
||||
SPI_CTAR_PBR(1) | SPI_CTAR_BR(0) | SPI_CTAR_DBR | SPI_CTAR_CSSCK(0),
|
||||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(0) | SPI_CTAR_CSSCK(0),
|
||||
SPI_CTAR_PBR(2) | SPI_CTAR_BR(0) | SPI_CTAR_DBR | SPI_CTAR_CSSCK(0),
|
||||
SPI_CTAR_PBR(1) | SPI_CTAR_BR(0) | SPI_CTAR_CSSCK(0),
|
||||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(1) | SPI_CTAR_CSSCK(1),
|
||||
SPI_CTAR_PBR(2) | SPI_CTAR_BR(0) | SPI_CTAR_CSSCK(0),
|
||||
SPI_CTAR_PBR(1) | SPI_CTAR_BR(1) | SPI_CTAR_CSSCK(1),
|
||||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(3) | SPI_CTAR_CSSCK(2),
|
||||
SPI_CTAR_PBR(2) | SPI_CTAR_BR(1) | SPI_CTAR_CSSCK(0),
|
||||
SPI_CTAR_PBR(1) | SPI_CTAR_BR(3) | SPI_CTAR_CSSCK(2),
|
||||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(4) | SPI_CTAR_CSSCK(3),
|
||||
SPI_CTAR_PBR(2) | SPI_CTAR_BR(3) | SPI_CTAR_CSSCK(2),
|
||||
SPI_CTAR_PBR(3) | SPI_CTAR_BR(3) | SPI_CTAR_CSSCK(2),
|
||||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(5) | SPI_CTAR_CSSCK(4),
|
||||
SPI_CTAR_PBR(1) | SPI_CTAR_BR(5) | SPI_CTAR_CSSCK(4),
|
||||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(6) | SPI_CTAR_CSSCK(5),
|
||||
SPI_CTAR_PBR(1) | SPI_CTAR_BR(6) | SPI_CTAR_CSSCK(5),
|
||||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(7) | SPI_CTAR_CSSCK(6),
|
||||
SPI_CTAR_PBR(1) | SPI_CTAR_BR(7) | SPI_CTAR_CSSCK(6),
|
||||
SPI_CTAR_PBR(0) | SPI_CTAR_BR(8) | SPI_CTAR_CSSCK(7),
|
||||
SPI_CTAR_PBR(2) | SPI_CTAR_BR(7) | SPI_CTAR_CSSCK(6),
|
||||
SPI_CTAR_PBR(1) | SPI_CTAR_BR(8) | SPI_CTAR_CSSCK(7)
|
||||
};
|
||||
|
||||
static void updateCTAR(uint32_t ctar)
|
||||
{
|
||||
if (SPI0_CTAR0 != ctar) {
|
||||
uint32_t mcr = SPI0_MCR;
|
||||
if (mcr & SPI_MCR_MDIS) {
|
||||
SPI0_CTAR0 = ctar;
|
||||
SPI0_CTAR1 = ctar | SPI_CTAR_FMSZ(8);
|
||||
} else {
|
||||
SPI0_MCR = SPI_MCR_MDIS | SPI_MCR_HALT | SPI_MCR_PCSIS(0x1F);
|
||||
SPI0_CTAR0 = ctar;
|
||||
SPI0_CTAR1 = ctar | SPI_CTAR_FMSZ(8);
|
||||
SPI0_MCR = mcr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SPIClass::setBitOrder(uint8_t bitOrder)
|
||||
{
|
||||
SIM_SCGC6 |= SIM_SCGC6_SPI0;
|
||||
uint32_t ctar = SPI0_CTAR0;
|
||||
if (bitOrder == LSBFIRST) {
|
||||
ctar |= SPI_CTAR_LSBFE;
|
||||
} else {
|
||||
ctar &= ~SPI_CTAR_LSBFE;
|
||||
}
|
||||
updateCTAR(ctar);
|
||||
}
|
||||
|
||||
void SPIClass::setDataMode(uint8_t dataMode)
|
||||
{
|
||||
SIM_SCGC6 |= SIM_SCGC6_SPI0;
|
||||
|
||||
// TODO: implement with native code
|
||||
|
||||
SPCR = (SPCR & ~SPI_MODE_MASK) | dataMode;
|
||||
}
|
||||
|
||||
void SPIClass::setClockDivider_noInline(uint32_t clk)
|
||||
{
|
||||
SIM_SCGC6 |= SIM_SCGC6_SPI0;
|
||||
uint32_t ctar = SPI0_CTAR0;
|
||||
ctar &= (SPI_CTAR_CPOL | SPI_CTAR_CPHA | SPI_CTAR_LSBFE);
|
||||
if (ctar & SPI_CTAR_CPHA) {
|
||||
clk = (clk & 0xFFFF0FFF) | ((clk & 0xF000) >> 4);
|
||||
}
|
||||
ctar |= clk;
|
||||
updateCTAR(ctar);
|
||||
}
|
||||
|
||||
bool SPIClass::pinIsChipSelect(uint8_t pin)
|
||||
{
|
||||
if (pin == 10 || pin == 9 || pin == 6 || pin == 2 || pin == 15) return true;
|
||||
if (pin >= 20 && pin <= 23) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SPIClass::pinIsChipSelect(uint8_t pin1, uint8_t pin2)
|
||||
{
|
||||
if (!pinIsChipSelect(pin1) || !pinIsChipSelect(pin2)) return false;
|
||||
if ((pin1 == 2 && pin2 == 10) || (pin1 == 10 && pin2 == 2)) return false;
|
||||
if ((pin1 == 6 && pin2 == 9) || (pin1 == 9 && pin2 == 6)) return false;
|
||||
if ((pin1 == 20 && pin2 == 23) || (pin1 == 23 && pin2 == 20)) return false;
|
||||
if ((pin1 == 21 && pin2 == 22) || (pin1 == 22 && pin2 == 21)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t SPIClass::setCS(uint8_t pin)
|
||||
{
|
||||
switch (pin) {
|
||||
case 10: CORE_PIN10_CONFIG = PORT_PCR_MUX(2); return 0x01; // PTC4
|
||||
case 2: CORE_PIN2_CONFIG = PORT_PCR_MUX(2); return 0x01; // PTD0
|
||||
case 9: CORE_PIN9_CONFIG = PORT_PCR_MUX(2); return 0x02; // PTC3
|
||||
case 6: CORE_PIN6_CONFIG = PORT_PCR_MUX(2); return 0x02; // PTD4
|
||||
case 20: CORE_PIN20_CONFIG = PORT_PCR_MUX(2); return 0x04; // PTD5
|
||||
case 23: CORE_PIN23_CONFIG = PORT_PCR_MUX(2); return 0x04; // PTC2
|
||||
case 21: CORE_PIN21_CONFIG = PORT_PCR_MUX(2); return 0x08; // PTD6
|
||||
case 22: CORE_PIN22_CONFIG = PORT_PCR_MUX(2); return 0x08; // PTC1
|
||||
case 15: CORE_PIN15_CONFIG = PORT_PCR_MUX(2); return 0x10; // PTC0
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
/* 32 bit Teensy-LC */
|
||||
/**********************************************************/
|
||||
|
||||
#elif defined(__arm__) && defined(TEENSYDUINO) && defined(KINETISL)
|
||||
|
||||
SPIClass SPI;
|
||||
SPI1Class SPI1;
|
||||
|
||||
uint32_t SPIClass::interruptMask = 0;
|
||||
uint32_t SPIClass::interruptSave = 0;
|
||||
uint32_t SPI1Class::interruptMask = 0;
|
||||
uint32_t SPI1Class::interruptSave = 0;
|
||||
#ifdef SPI_TRANSACTION_MISMATCH_LED
|
||||
uint8_t SPIClass::inTransactionFlag = 0;
|
||||
uint8_t SPI1Class::inTransactionFlag = 0;
|
||||
#endif
|
||||
|
||||
void SPIClass::begin()
|
||||
{
|
||||
SIM_SCGC4 |= SIM_SCGC4_SPI0;
|
||||
SPI0_C1 = SPI_C1_SPE | SPI_C1_MSTR;
|
||||
SPI0_C2 = 0;
|
||||
uint8_t tmp __attribute__((unused)) = SPI0_S;
|
||||
SPCR.enable_pins(); // pins managed by SPCRemulation in avr_emulation.h
|
||||
}
|
||||
|
||||
void SPIClass::end() {
|
||||
SPCR.disable_pins();
|
||||
SPI0_C1 = 0;
|
||||
}
|
||||
|
||||
const uint16_t SPISettings::br_div_table[30] = {
|
||||
2, 4, 6, 8, 10, 12, 14, 16, 20, 24,
|
||||
28, 32, 40, 48, 56, 64, 80, 96, 112, 128,
|
||||
160, 192, 224, 256, 320, 384, 448, 512, 640, 768,
|
||||
};
|
||||
|
||||
const uint8_t SPISettings::br_clock_table[30] = {
|
||||
SPI_BR_SPPR(0) | SPI_BR_SPR(0),
|
||||
SPI_BR_SPPR(1) | SPI_BR_SPR(0),
|
||||
SPI_BR_SPPR(2) | SPI_BR_SPR(0),
|
||||
SPI_BR_SPPR(3) | SPI_BR_SPR(0),
|
||||
SPI_BR_SPPR(4) | SPI_BR_SPR(0),
|
||||
SPI_BR_SPPR(5) | SPI_BR_SPR(0),
|
||||
SPI_BR_SPPR(6) | SPI_BR_SPR(0),
|
||||
SPI_BR_SPPR(7) | SPI_BR_SPR(0),
|
||||
SPI_BR_SPPR(4) | SPI_BR_SPR(1),
|
||||
SPI_BR_SPPR(5) | SPI_BR_SPR(1),
|
||||
SPI_BR_SPPR(6) | SPI_BR_SPR(1),
|
||||
SPI_BR_SPPR(7) | SPI_BR_SPR(1),
|
||||
SPI_BR_SPPR(4) | SPI_BR_SPR(2),
|
||||
SPI_BR_SPPR(5) | SPI_BR_SPR(2),
|
||||
SPI_BR_SPPR(6) | SPI_BR_SPR(2),
|
||||
SPI_BR_SPPR(7) | SPI_BR_SPR(2),
|
||||
SPI_BR_SPPR(4) | SPI_BR_SPR(3),
|
||||
SPI_BR_SPPR(5) | SPI_BR_SPR(3),
|
||||
SPI_BR_SPPR(6) | SPI_BR_SPR(3),
|
||||
SPI_BR_SPPR(7) | SPI_BR_SPR(3),
|
||||
SPI_BR_SPPR(4) | SPI_BR_SPR(4),
|
||||
SPI_BR_SPPR(5) | SPI_BR_SPR(4),
|
||||
SPI_BR_SPPR(6) | SPI_BR_SPR(4),
|
||||
SPI_BR_SPPR(7) | SPI_BR_SPR(4),
|
||||
SPI_BR_SPPR(4) | SPI_BR_SPR(5),
|
||||
SPI_BR_SPPR(5) | SPI_BR_SPR(5),
|
||||
SPI_BR_SPPR(6) | SPI_BR_SPR(5),
|
||||
SPI_BR_SPPR(7) | SPI_BR_SPR(5),
|
||||
SPI_BR_SPPR(4) | SPI_BR_SPR(6),
|
||||
SPI_BR_SPPR(5) | SPI_BR_SPR(6)
|
||||
};
|
||||
|
||||
uint8_t SPIClass::setCS(uint8_t pin)
|
||||
{
|
||||
switch (pin) {
|
||||
case 10: CORE_PIN10_CONFIG = PORT_PCR_MUX(2); return 0x01; // PTC4
|
||||
case 2: CORE_PIN2_CONFIG = PORT_PCR_MUX(2); return 0x01; // PTD0
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SPI1Class::begin()
|
||||
{
|
||||
SIM_SCGC4 |= SIM_SCGC4_SPI1;
|
||||
SPI1_C1 = SPI_C1_SPE | SPI_C1_MSTR;
|
||||
SPI1_C2 = 0;
|
||||
uint8_t tmp __attribute__((unused)) = SPI1_S;
|
||||
SPCR1.enable_pins(); // pins managed by SPCRemulation in avr_emulation.h
|
||||
}
|
||||
|
||||
void SPI1Class::end() {
|
||||
SPCR1.disable_pins();
|
||||
SPI1_C1 = 0;
|
||||
}
|
||||
|
||||
uint8_t SPI1Class::setCS(uint8_t pin)
|
||||
{
|
||||
switch (pin) {
|
||||
case 6: CORE_PIN6_CONFIG = PORT_PCR_MUX(2); return 0x01; // PTD4
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
/* 32 bit Arduino Due */
|
||||
/**********************************************************/
|
||||
|
||||
#elif defined(__arm__) && defined(__SAM3X8E__)
|
||||
|
||||
#include "SPI.h"
|
||||
|
||||
|
||||
SPIClass::SPIClass(Spi *_spi, uint32_t _id, void(*_initCb)(void)) :
|
||||
spi(_spi), id(_id), initCb(_initCb), initialized(false)
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
void SPIClass::begin() {
|
||||
init();
|
||||
// NPCS control is left to the user
|
||||
|
||||
// Default speed set to 4Mhz
|
||||
setClockDivider(BOARD_SPI_DEFAULT_SS, 21);
|
||||
setDataMode(BOARD_SPI_DEFAULT_SS, SPI_MODE0);
|
||||
setBitOrder(BOARD_SPI_DEFAULT_SS, MSBFIRST);
|
||||
}
|
||||
|
||||
void SPIClass::begin(uint8_t _pin) {
|
||||
init();
|
||||
|
||||
uint32_t spiPin = BOARD_PIN_TO_SPI_PIN(_pin);
|
||||
PIO_Configure(
|
||||
g_APinDescription[spiPin].pPort,
|
||||
g_APinDescription[spiPin].ulPinType,
|
||||
g_APinDescription[spiPin].ulPin,
|
||||
g_APinDescription[spiPin].ulPinConfiguration);
|
||||
|
||||
// Default speed set to 4Mhz
|
||||
setClockDivider(_pin, 21);
|
||||
setDataMode(_pin, SPI_MODE0);
|
||||
setBitOrder(_pin, MSBFIRST);
|
||||
}
|
||||
|
||||
void SPIClass::init() {
|
||||
if (initialized)
|
||||
return;
|
||||
interruptMode = 0;
|
||||
interruptMask = 0;
|
||||
interruptSave = 0;
|
||||
initCb();
|
||||
SPI_Configure(spi, id, SPI_MR_MSTR | SPI_MR_PS | SPI_MR_MODFDIS);
|
||||
SPI_Enable(spi);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
#ifndef interruptsStatus
|
||||
#define interruptsStatus() __interruptsStatus()
|
||||
static inline unsigned char __interruptsStatus(void) __attribute__((always_inline, unused));
|
||||
static inline unsigned char __interruptsStatus(void) {
|
||||
unsigned int primask;
|
||||
asm volatile ("mrs %0, primask" : "=r" (primask));
|
||||
if (primask) return 0;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void SPIClass::usingInterrupt(uint8_t interruptNumber)
|
||||
{
|
||||
uint8_t irestore;
|
||||
|
||||
irestore = interruptsStatus();
|
||||
noInterrupts();
|
||||
if (interruptMode < 2) {
|
||||
if (interruptNumber > NUM_DIGITAL_PINS) {
|
||||
interruptMode = 2;
|
||||
} else {
|
||||
uint8_t imask = interruptMask;
|
||||
Pio *pio = g_APinDescription[interruptNumber].pPort;
|
||||
if (pio == PIOA) {
|
||||
imask |= 1;
|
||||
} else if (pio == PIOB) {
|
||||
imask |= 2;
|
||||
} else if (pio == PIOC) {
|
||||
imask |= 4;
|
||||
} else if (pio == PIOD) {
|
||||
imask |= 8;
|
||||
}
|
||||
interruptMask = imask;
|
||||
interruptMode = 1;
|
||||
}
|
||||
}
|
||||
if (irestore) interrupts();
|
||||
}
|
||||
|
||||
void SPIClass::beginTransaction(uint8_t pin, SPISettings settings)
|
||||
{
|
||||
if (interruptMode > 0) {
|
||||
if (interruptMode == 1) {
|
||||
uint8_t imask = interruptMask;
|
||||
if (imask & 1) NVIC_DisableIRQ(PIOA_IRQn);
|
||||
if (imask & 2) NVIC_DisableIRQ(PIOB_IRQn);
|
||||
if (imask & 4) NVIC_DisableIRQ(PIOC_IRQn);
|
||||
if (imask & 8) NVIC_DisableIRQ(PIOD_IRQn);
|
||||
} else {
|
||||
interruptSave = interruptsStatus();
|
||||
noInterrupts();
|
||||
}
|
||||
}
|
||||
uint32_t ch = BOARD_PIN_TO_SPI_CHANNEL(pin);
|
||||
bitOrder[ch] = settings.border;
|
||||
SPI_ConfigureNPCS(spi, ch, settings.config);
|
||||
}
|
||||
|
||||
void SPIClass::endTransaction(void)
|
||||
{
|
||||
if (interruptMode > 0) {
|
||||
if (interruptMode == 1) {
|
||||
uint8_t imask = interruptMask;
|
||||
if (imask & 1) NVIC_EnableIRQ(PIOA_IRQn);
|
||||
if (imask & 2) NVIC_EnableIRQ(PIOB_IRQn);
|
||||
if (imask & 4) NVIC_EnableIRQ(PIOC_IRQn);
|
||||
if (imask & 8) NVIC_EnableIRQ(PIOD_IRQn);
|
||||
} else {
|
||||
if (interruptSave) interrupts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SPIClass::end(uint8_t _pin) {
|
||||
uint32_t spiPin = BOARD_PIN_TO_SPI_PIN(_pin);
|
||||
// Setting the pin as INPUT will disconnect it from SPI peripheral
|
||||
pinMode(spiPin, INPUT);
|
||||
}
|
||||
|
||||
void SPIClass::end() {
|
||||
SPI_Disable(spi);
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
void SPIClass::setBitOrder(uint8_t _pin, BitOrder _bitOrder) {
|
||||
uint32_t ch = BOARD_PIN_TO_SPI_CHANNEL(_pin);
|
||||
bitOrder[ch] = _bitOrder;
|
||||
}
|
||||
|
||||
void SPIClass::setDataMode(uint8_t _pin, uint8_t _mode) {
|
||||
uint32_t ch = BOARD_PIN_TO_SPI_CHANNEL(_pin);
|
||||
mode[ch] = _mode | SPI_CSR_CSAAT;
|
||||
// SPI_CSR_DLYBCT(1) keeps CS enabled for 32 MCLK after a completed
|
||||
// transfer. Some device needs that for working properly.
|
||||
SPI_ConfigureNPCS(spi, ch, mode[ch] | SPI_CSR_SCBR(divider[ch]) | SPI_CSR_DLYBCT(1));
|
||||
}
|
||||
|
||||
void SPIClass::setClockDivider(uint8_t _pin, uint8_t _divider) {
|
||||
uint32_t ch = BOARD_PIN_TO_SPI_CHANNEL(_pin);
|
||||
divider[ch] = _divider;
|
||||
// SPI_CSR_DLYBCT(1) keeps CS enabled for 32 MCLK after a completed
|
||||
// transfer. Some device needs that for working properly.
|
||||
SPI_ConfigureNPCS(spi, ch, mode[ch] | SPI_CSR_SCBR(divider[ch]) | SPI_CSR_DLYBCT(1));
|
||||
}
|
||||
|
||||
byte SPIClass::transfer(byte _pin, uint8_t _data, SPITransferMode _mode) {
|
||||
uint32_t ch = BOARD_PIN_TO_SPI_CHANNEL(_pin);
|
||||
// Reverse bit order
|
||||
if (bitOrder[ch] == LSBFIRST)
|
||||
_data = __REV(__RBIT(_data));
|
||||
uint32_t d = _data | SPI_PCS(ch);
|
||||
if (_mode == SPI_LAST)
|
||||
d |= SPI_TDR_LASTXFER;
|
||||
|
||||
// SPI_Write(spi, _channel, _data);
|
||||
while ((spi->SPI_SR & SPI_SR_TDRE) == 0)
|
||||
;
|
||||
spi->SPI_TDR = d;
|
||||
|
||||
// return SPI_Read(spi);
|
||||
while ((spi->SPI_SR & SPI_SR_RDRF) == 0)
|
||||
;
|
||||
d = spi->SPI_RDR;
|
||||
// Reverse bit order
|
||||
if (bitOrder[ch] == LSBFIRST)
|
||||
d = __REV(__RBIT(d));
|
||||
return d & 0xFF;
|
||||
}
|
||||
|
||||
void SPIClass::attachInterrupt(void) {
|
||||
// Should be enableInterrupt()
|
||||
}
|
||||
|
||||
void SPIClass::detachInterrupt(void) {
|
||||
// Should be disableInterrupt()
|
||||
}
|
||||
|
||||
#if SPI_INTERFACES_COUNT > 0
|
||||
static void SPI_0_Init(void) {
|
||||
PIO_Configure(
|
||||
g_APinDescription[PIN_SPI_MOSI].pPort,
|
||||
g_APinDescription[PIN_SPI_MOSI].ulPinType,
|
||||
g_APinDescription[PIN_SPI_MOSI].ulPin,
|
||||
g_APinDescription[PIN_SPI_MOSI].ulPinConfiguration);
|
||||
PIO_Configure(
|
||||
g_APinDescription[PIN_SPI_MISO].pPort,
|
||||
g_APinDescription[PIN_SPI_MISO].ulPinType,
|
||||
g_APinDescription[PIN_SPI_MISO].ulPin,
|
||||
g_APinDescription[PIN_SPI_MISO].ulPinConfiguration);
|
||||
PIO_Configure(
|
||||
g_APinDescription[PIN_SPI_SCK].pPort,
|
||||
g_APinDescription[PIN_SPI_SCK].ulPinType,
|
||||
g_APinDescription[PIN_SPI_SCK].ulPin,
|
||||
g_APinDescription[PIN_SPI_SCK].ulPinConfiguration);
|
||||
}
|
||||
|
||||
SPIClass SPI(SPI_INTERFACE, SPI_INTERFACE_ID, SPI_0_Init);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
105
Streaming/Streaming.h
Normal file
105
Streaming/Streaming.h
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
Streaming.h - Arduino library for supporting the << streaming operator
|
||||
Copyright (c) 2010-2012 Mikal Hart. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef ARDUINO_STREAMING
|
||||
#define ARDUINO_STREAMING
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#define STREAMING_LIBRARY_VERSION 5
|
||||
|
||||
// Generic template
|
||||
template<class T>
|
||||
inline Print &operator <<(Print &stream, T arg)
|
||||
{ stream.print(arg); return stream; }
|
||||
|
||||
struct _BASED
|
||||
{
|
||||
long val;
|
||||
int base;
|
||||
_BASED(long v, int b): val(v), base(b)
|
||||
{}
|
||||
};
|
||||
|
||||
#if ARDUINO >= 100
|
||||
|
||||
struct _BYTE_CODE
|
||||
{
|
||||
byte val;
|
||||
_BYTE_CODE(byte v) : val(v)
|
||||
{}
|
||||
};
|
||||
#define _BYTE(a) _BYTE_CODE(a)
|
||||
|
||||
inline Print &operator <<(Print &obj, const _BYTE_CODE &arg)
|
||||
{ obj.write(arg.val); return obj; }
|
||||
|
||||
#else
|
||||
|
||||
#define _BYTE(a) _BASED(a, BYTE)
|
||||
|
||||
#endif
|
||||
|
||||
#define _HEX(a) _BASED(a, HEX)
|
||||
#define _DEC(a) _BASED(a, DEC)
|
||||
#define _OCT(a) _BASED(a, OCT)
|
||||
#define _BIN(a) _BASED(a, BIN)
|
||||
|
||||
// Specialization for class _BASED
|
||||
// Thanks to Arduino forum user Ben Combee who suggested this
|
||||
// clever technique to allow for expressions like
|
||||
// Serial << _HEX(a);
|
||||
|
||||
inline Print &operator <<(Print &obj, const _BASED &arg)
|
||||
{ obj.print(arg.val, arg.base); return obj; }
|
||||
|
||||
#if ARDUINO >= 18
|
||||
// Specialization for class _FLOAT
|
||||
// Thanks to Michael Margolis for suggesting a way
|
||||
// to accommodate Arduino 0018's floating point precision
|
||||
// feature like this:
|
||||
// Serial << _FLOAT(gps_latitude, 6); // 6 digits of precision
|
||||
|
||||
struct _FLOAT
|
||||
{
|
||||
float val;
|
||||
int digits;
|
||||
_FLOAT(double v, int d): val(v), digits(d)
|
||||
{}
|
||||
};
|
||||
|
||||
inline Print &operator <<(Print &obj, const _FLOAT &arg)
|
||||
{ obj.print(arg.val, arg.digits); return obj; }
|
||||
#endif
|
||||
|
||||
// Specialization for enum _EndLineCode
|
||||
// Thanks to Arduino forum user Paul V. who suggested this
|
||||
// clever technique to allow for expressions like
|
||||
// Serial << "Hello!" << endl;
|
||||
|
||||
enum _EndLineCode { endl };
|
||||
|
||||
inline Print &operator <<(Print &obj, _EndLineCode arg)
|
||||
{ obj.println(); return obj; }
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user