add libraries, WiFi works
This commit is contained in:
parent
444ace95e0
commit
7ec78fbb6d
26
.cproject
26
.cproject
@ -25,18 +25,18 @@
|
|||||||
<option id="it.baeyens.arduino.compiler.cpp.sketch.option.incpath.660768886" name="Include Paths (-I)" superClass="it.baeyens.arduino.compiler.cpp.sketch.option.incpath" valueType="includePath">
|
<option id="it.baeyens.arduino.compiler.cpp.sketch.option.incpath.660768886" name="Include Paths (-I)" superClass="it.baeyens.arduino.compiler.cpp.sketch.option.incpath" valueType="includePath">
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/arduino/core}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/arduino/core}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/arduino/variant}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/arduino/variant}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Libraries/SPI}""/>
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Adafruit-GFX}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Adafruit-GFX}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Metro}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Metro}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/MQTT}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/MQTT}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Streaming}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Streaming}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/TFT_ILI9341}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/TFT_ILI9341}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Touch-Screen}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Touch-Screen}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Libraries/WiFi}""/>
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Libraries/WiFi/src}""/>
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Adafruit_FT6206}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Adafruit_FT6206}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Libraries/Wire}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/core/core}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Libraries/Wire/utility}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/core/variant}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/WiFi}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Wire}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/SPI}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="it.baeyens.arduino.compiler.cpp.sketch.input.505756577" name="CPP source files" superClass="it.baeyens.arduino.compiler.cpp.sketch.input"/>
|
<inputType id="it.baeyens.arduino.compiler.cpp.sketch.input.505756577" name="CPP source files" superClass="it.baeyens.arduino.compiler.cpp.sketch.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
@ -44,18 +44,18 @@
|
|||||||
<option id="it.baeyens.arduino.compiler.c.sketch.option.incpath.2126801261" name="Include Paths (-I)" superClass="it.baeyens.arduino.compiler.c.sketch.option.incpath" valueType="includePath">
|
<option id="it.baeyens.arduino.compiler.c.sketch.option.incpath.2126801261" name="Include Paths (-I)" superClass="it.baeyens.arduino.compiler.c.sketch.option.incpath" valueType="includePath">
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/arduino/core}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/arduino/core}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/arduino/variant}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/arduino/variant}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Libraries/SPI}""/>
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Adafruit-GFX}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Adafruit-GFX}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Metro}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Metro}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/MQTT}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/MQTT}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Streaming}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Streaming}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/TFT_ILI9341}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/TFT_ILI9341}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Touch-Screen}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Touch-Screen}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Libraries/WiFi}""/>
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Libraries/WiFi/src}""/>
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Adafruit_FT6206}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Adafruit_FT6206}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Libraries/Wire}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/core/core}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Libraries/Wire/utility}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/core/variant}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/WiFi}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/Wire}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/MqttMonitor/SPI}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="it.baeyens.arduino.compiler.c.sketch.input.575652065" name="C Source Files" superClass="it.baeyens.arduino.compiler.c.sketch.input"/>
|
<inputType id="it.baeyens.arduino.compiler.c.sketch.input.575652065" name="C Source Files" superClass="it.baeyens.arduino.compiler.c.sketch.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
@ -68,14 +68,17 @@
|
|||||||
</toolChain>
|
</toolChain>
|
||||||
</folderInfo>
|
</folderInfo>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry excluding="Adafruit_FT6206|Adafruit-GFX|Libraries/*/?xamples|Streaming|MQTT|TFT_ILI9341|Libraries/*/?xtras|Metro|Touch-Screen|TFTLCD" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
<entry excluding="Wire|SPI|WiFi|Adafruit_FT6206|Adafruit-GFX|Libraries/*/?xamples|Streaming|MQTT|TFT_ILI9341|Libraries/*/?xtras|Metro|Touch-Screen|TFTLCD" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Adafruit-GFX"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Adafruit-GFX"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Adafruit_FT6206"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Adafruit_FT6206"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="MQTT"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="MQTT"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Metro"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Metro"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="SPI"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Streaming"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Streaming"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="TFT_ILI9341"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="TFT_ILI9341"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Touch-Screen"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Touch-Screen"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="WiFi"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Wire"/>
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
@ -95,4 +98,5 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||||
</cproject>
|
</cproject>
|
||||||
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/Release/
|
@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
syntax: glob
|
|
||||||
.DS_Store
|
|
||||||
syntax: regexp
|
|
||||||
.DS_Store
|
|
||||||
syntax: regexp
|
|
||||||
^Release$
|
|
25
.project
25
.project
@ -26,21 +26,6 @@
|
|||||||
<nature>it.baeyens.arduinonature</nature>
|
<nature>it.baeyens.arduinonature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
<linkedResources>
|
<linkedResources>
|
||||||
<link>
|
|
||||||
<name>Libraries/SPI</name>
|
|
||||||
<type>2</type>
|
|
||||||
<locationURI>ArduinoHardwareLibPath/SPI</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>Libraries/WiFi</name>
|
|
||||||
<type>2</type>
|
|
||||||
<locationURI>ArduinoLibPath/WiFi</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>Libraries/Wire</name>
|
|
||||||
<type>2</type>
|
|
||||||
<locationURI>ArduinoHardwareLibPath/Wire</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
<link>
|
||||||
<name>arduino/core</name>
|
<name>arduino/core</name>
|
||||||
<type>2</type>
|
<type>2</type>
|
||||||
@ -51,6 +36,16 @@
|
|||||||
<type>2</type>
|
<type>2</type>
|
||||||
<locationURI>ArduinoPinPath/mega</locationURI>
|
<locationURI>ArduinoPinPath/mega</locationURI>
|
||||||
</link>
|
</link>
|
||||||
|
<link>
|
||||||
|
<name>core/core</name>
|
||||||
|
<type>2</type>
|
||||||
|
<location>/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.14/cores/arduino</location>
|
||||||
|
</link>
|
||||||
|
<link>
|
||||||
|
<name>core/variant</name>
|
||||||
|
<type>2</type>
|
||||||
|
<location>/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.14/variants/mega</location>
|
||||||
|
</link>
|
||||||
</linkedResources>
|
</linkedResources>
|
||||||
<variableList>
|
<variableList>
|
||||||
<variable>
|
<variable>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="it.baeyens.arduino.toolchain.ArduinoLanguageProvider" console="false" env-hash="-1715691784350573403" 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="711432436404618007" 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.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ALT_SIZE_COMMAND/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ALT_SIZE_COMMAND/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ALT_SIZE_COMMAND/value="${A.COMPILER.PATH}${A.COMPILER.SIZE.CMD}" --format\=avr --mcu\=${A.BUILD.MCU} "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf"
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHITECTURE/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHITECTURE/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHITECTURE/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHITECTURE/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHITECTURE/value=AVR
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHITECTURE/value=AVR
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHIVE_FILE/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHIVE_FILE/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHIVE_FILE/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHIVE_FILE/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHIVE_FILE/value=arduino.ar
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHIVE_FILE/value=arduino.ar
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHIVE_FILE_PATH/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHIVE_FILE_PATH/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.ARCHIVE_FILE_PATH/value=${A.BUILD.PATH}/${A.ARCHIVE_FILE}
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BOOTLOADER.EXTENDED_FUSES/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BOOTLOADER.EXTENDED_FUSES/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BOOTLOADER.EXTENDED_FUSES/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BOOTLOADER.EXTENDED_FUSES/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BOOTLOADER.EXTENDED_FUSES/value=0xFD
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BOOTLOADER.EXTENDED_FUSES/value=0xFD
|
||||||
@ -53,33 +59,27 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.PROJECT_NAME/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.PROJECT_NAME/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.PROJECT_NAME/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.PROJECT_NAME/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.PROJECT_NAME/value=${ProjName}
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.PROJECT_NAME/value=${ProjName}
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.SYSTEM.PATH/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.SYSTEM.PATH/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.SYSTEM.PATH/value=${A.RUNTIME.PLATFORM.PATH}/system
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS.WINDOWS/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS.WINDOWS/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS.WINDOWS/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS.WINDOWS/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS.WINDOWS/value=-DUSB_VID\=${A.BUILD.VID} -DUSB_PID\=${A.BUILD.PID} -DUSB_MANUFACTURER\=\\"${A.BUILD.USB_MANUFACTURER}\\" -DUSB_PRODUCT\=\\"${A.BUILD.USB_PRODUCT}\\"
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS.WINDOWS/value=-DUSB_VID\=${A.BUILD.VID} -DUSB_PID\=${A.BUILD.PID} -DUSBCON -DUSB_MANUFACTURER\=\\"${A.BUILD.USB_MANUFACTURER}\\" -DUSB_PRODUCT\=\\"${A.BUILD.USB_PRODUCT}\\"
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS/value=-DUSB_VID\=${A.BUILD.VID} -DUSB_PID\=${A.BUILD.PID} '-DUSB_MANUFACTURER\=${A.BUILD.USB_MANUFACTURER}' '-DUSB_PRODUCT\=${A.BUILD.USB_PRODUCT}'
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_FLAGS/value=-DUSB_VID\=${A.BUILD.VID} -DUSB_PID\=${A.BUILD.PID} '-DUSB_MANUFACTURER\=${A.BUILD.USB_MANUFACTURER}' '-DUSB_PRODUCT\=${A.BUILD.USB_PRODUCT}'
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_MANUFACTURER/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_MANUFACTURER/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_MANUFACTURER/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_MANUFACTURER/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_MANUFACTURER/value="Unknown"
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USB_MANUFACTURER/value="Unknown"
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USE_ARCHIVER/delimiter=\:
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USE_ARCHIVER/operation=replace
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.USE_ARCHIVER/value=true
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT.PATH/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT.PATH/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT.PATH/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT.PATH/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT.PATH/value=${A.RUNTIME.PLATFORM.PATH}/variants/${A.BUILD.VARIANT}
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT.PATH/value=${A.RUNTIME.PLATFORM.PATH}/variants/${A.BUILD.VARIANT}
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT/value=${JANTJE.BUILD_VARIANT}
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.BUILD.VARIANT/value=${JANTJE.BUILD_VARIANT}
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.CMD.PATH/delimiter=\:
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.CMD.PATH/operation=replace
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.CMD.PATH/value=${A.TOOLS.AVRDUDE.CMD.PATH}
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.CMD/delimiter=\:
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.CMD/operation=replace
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.CMD/value=${A.TOOLS.AVRDUDE.CMD}
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.CMD/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.CMD/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.CMD/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.CMD/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.CMD/value=avr-ar
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.CMD/value=avr-gcc-ar
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.EXTRA_FLAGS/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.EXTRA_FLAGS/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.EXTRA_FLAGS/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.EXTRA_FLAGS/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.EXTRA_FLAGS/value=
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.AR.EXTRA_FLAGS/value=
|
||||||
@ -103,7 +103,7 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPI
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.C.EXTRA_FLAGS/value=
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.C.EXTRA_FLAGS/value=
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.C.FLAGS/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.C.FLAGS/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.C.FLAGS/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.C.FLAGS/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.C.FLAGS/value=-c -g -Os -w -ffunction-sections -fdata-sections -MMD
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.C.FLAGS/value=-c -g -Os ${A.COMPILER.WARNING_FLAGS} -std\=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.CMD/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.CMD/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.CMD/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.CMD/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.CMD/value=avr-g++
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.CMD/value=avr-g++
|
||||||
@ -112,7 +112,7 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPI
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.EXTRA_FLAGS/value=
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.EXTRA_FLAGS/value=
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.FLAGS/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.FLAGS/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.FLAGS/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.FLAGS/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.FLAGS/value=-c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.CPP.FLAGS/value=-c -g -Os ${A.COMPILER.WARNING_FLAGS} -std\=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.ELF2HEX.CMD/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.ELF2HEX.CMD/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.ELF2HEX.CMD/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.ELF2HEX.CMD/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.ELF2HEX.CMD/value=avr-objcopy
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.ELF2HEX.CMD/value=avr-objcopy
|
||||||
@ -136,34 +136,46 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPI
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/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.1898938335/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.1898938335/A.COMPILER.PATH/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.PATH/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.PATH/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.PATH/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.PATH/value=${A.RUNTIME.IDE.PATH}/hardware/tools/avr/bin/
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.PATH/value=${A.RUNTIME.TOOLS.AVR-GCC.PATH}/bin/
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.EXTRA_FLAGS/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.EXTRA_FLAGS/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.EXTRA_FLAGS/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.EXTRA_FLAGS/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.EXTRA_FLAGS/value=
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.EXTRA_FLAGS/value=
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.FLAGS/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.FLAGS/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.FLAGS/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.FLAGS/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.FLAGS/value=-c -g -x assembler-with-cpp
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.S.FLAGS/value=-c -g -x assembler-with-cpp -flto
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.SIZE.CMD/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.SIZE.CMD/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.SIZE.CMD/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.SIZE.CMD/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.SIZE.CMD/value=avr-size
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.SIZE.CMD/value=avr-size
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.CONFIG.PATH/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.ALL/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.CONFIG.PATH/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.ALL/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.CONFIG.PATH/value=${A.TOOLS.AVRDUDE.CONFIG.PATH}
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.ALL/value=-Wall -Wextra
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.DEFAULT/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.DEFAULT/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.DEFAULT/value=
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.MORE/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.MORE/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.MORE/value=-Wall
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.NONE/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.NONE/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS.NONE/value=-w
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.COMPILER.WARNING_FLAGS/value=-w
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.DTS/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.DTS/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.DTS/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.DTS/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.DTS/value=3600
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.DTS/value=3600
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.LOCAL/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.LOCAL/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.LOCAL/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.LOCAL/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.LOCAL/value=1468270614
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.LOCAL/value=1477784076
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.UTC/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.UTC/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.UTC/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.UTC/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.UTC/value=1468263414
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.UTC/value=1477776876
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.ZONE/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.ZONE/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.ZONE/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.ZONE/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.ZONE/value=3600
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.EXTRA.TIME.ZONE/value=3600
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.NAME/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.NAME/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.NAME/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.NAME/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.NAME/value=Arduino Mega or Mega 2560
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.NAME/value=Arduino/Genuino Mega or Mega 2560
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PATH/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PATH/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PATH/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PATH/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PATH/value=${A.TOOLS.AVRDUDE.PATH}
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PATH/value=${A.TOOLS.AVRDUDE.PATH}
|
||||||
@ -179,21 +191,36 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.2
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.3/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.3/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.3/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.3/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.3/value=0x0042
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.3/value=0x0042
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.4/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.4/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.4/value=0x0210
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.5/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.5/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PID.5/value=0x0242
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PREPROC.INCLUDES.FLAGS/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PREPROC.INCLUDES.FLAGS/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PREPROC.INCLUDES.FLAGS/value=-w -x c++ -M -MG -MP
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PREPROC.MACROS.FLAGS/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PREPROC.MACROS.FLAGS/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.PREPROC.MACROS.FLAGS/value=-w -x c++ -E -CC
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.1/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.1/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.1/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.1/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.AR.CMD}" ${A.COMPILER.AR.FLAGS} ${A.COMPILER.AR.EXTRA_FLAGS} "${A.BUILD.PATH}/${A.ARCHIVE_FILE}"
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.AR.CMD}" ${A.COMPILER.AR.FLAGS} ${A.COMPILER.AR.EXTRA_FLAGS} "${A.ARCHIVE_FILE_PATH}"
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.2/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.2/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.2/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.2/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.2/value=
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN.2/value=
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.AR.CMD}" ${A.COMPILER.AR.FLAGS} ${A.COMPILER.AR.EXTRA_FLAGS} "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" "${A.OBJECT_FILE}"
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.AR.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.AR.CMD}" ${A.COMPILER.AR.FLAGS} ${A.COMPILER.AR.EXTRA_FLAGS} "${A.ARCHIVE_FILE_PATH}" "${A.OBJECT_FILE}"
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.1/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.1/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.1/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.1/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.C.ELF.CMD}" ${A.COMPILER.C.ELF.FLAGS} -mmcu\=${A.BUILD.MCU} ${A.COMPILER.C.ELF.EXTRA_FLAGS} -o "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf"
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.C.ELF.CMD}" ${A.COMPILER.C.ELF.FLAGS} -mmcu\=${A.BUILD.MCU} ${A.COMPILER.C.ELF.EXTRA_FLAGS} -o "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf"
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.2/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.2/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.2/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.2/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.2/value=\ "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" "-L${A.BUILD.PATH}" -lm
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.2/value=\
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.3/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.3/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN.3/value=\ "-L${A.BUILD.PATH}" -lm
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.C.ELF.CMD}" ${A.COMPILER.C.ELF.FLAGS} -mmcu\=${A.BUILD.MCU} ${A.COMPILER.C.ELF.EXTRA_FLAGS} -o "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" ${A.OBJECT_FILES} "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" "-L${A.BUILD.PATH}" -lm
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.C.COMBINE.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.C.ELF.CMD}" ${A.COMPILER.C.ELF.FLAGS} -mmcu\=${A.BUILD.MCU} ${A.COMPILER.C.ELF.EXTRA_FLAGS} -o "${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.elf" ${A.OBJECT_FILES} "${A.BUILD.PATH}/${A.ARCHIVE_FILE}" "-L${A.BUILD.PATH}" -lm
|
||||||
@ -233,6 +260,18 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIP
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.OBJCOPY.HEX.PATTERN/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.OBJCOPY.HEX.PATTERN/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.OBJCOPY.HEX.PATTERN/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.OBJCOPY.HEX.PATTERN/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.OBJCOPY.HEX.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.ELF2HEX.CMD}" ${A.COMPILER.ELF2HEX.FLAGS} ${A.COMPILER.ELF2HEX.EXTRA_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.1898938335/A.RECIPE.OBJCOPY.HEX.PATTERN/value="${A.COMPILER.PATH}${A.COMPILER.ELF2HEX.CMD}" ${A.COMPILER.ELF2HEX.FLAGS} ${A.COMPILER.ELF2HEX.EXTRA_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.1898938335/A.RECIPE.OUTPUT.SAVE_FILE/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.OUTPUT.SAVE_FILE/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.OUTPUT.SAVE_FILE/value=${A.BUILD.PROJECT_NAME}.${A.BUILD.VARIANT}.hex
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.OUTPUT.TMP_FILE/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.OUTPUT.TMP_FILE/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.OUTPUT.TMP_FILE/value=${A.BUILD.PROJECT_NAME}.hex
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.PREPROC.INCLUDES/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.PREPROC.INCLUDES/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.PREPROC.INCLUDES/value="${A.COMPILER.PATH}${A.COMPILER.CPP.CMD}" ${A.COMPILER.CPP.FLAGS} ${A.PREPROC.INCLUDES.FLAGS} -mmcu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} ${A.COMPILER.CPP.EXTRA_FLAGS} ${A.BUILD.EXTRA_FLAGS} ${A.INCLUDES} "${A.SOURCE_FILE}"
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.PREPROC.MACROS/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.PREPROC.MACROS/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.PREPROC.MACROS/value="${A.COMPILER.PATH}${A.COMPILER.CPP.CMD}" ${A.COMPILER.CPP.FLAGS} ${A.PREPROC.MACROS.FLAGS} -mmcu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} ${A.COMPILER.CPP.EXTRA_FLAGS} ${A.BUILD.EXTRA_FLAGS} ${A.INCLUDES} "${A.SOURCE_FILE}" -o "${A.PREPROCESSED_FILE_PATH}"
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.S.O.PATTERN.1/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.S.O.PATTERN.1/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.S.O.PATTERN.1/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.S.O.PATTERN.1/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.S.O.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.C.CMD}" ${A.COMPILER.S.FLAGS} -mmcu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} ${A.COMPILER.S.EXTRA_FLAGS} ${A.BUILD.EXTRA_FLAGS} ${A.INCLUDES}
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.S.O.PATTERN.1/value="${A.COMPILER.PATH}${A.COMPILER.C.CMD}" ${A.COMPILER.S.FLAGS} -mmcu\=${A.BUILD.MCU} -DF_CPU\=${A.BUILD.F_CPU} -DARDUINO\=${A.RUNTIME.IDE.VERSION} -DARDUINO_${A.BUILD.BOARD} -DARDUINO_ARCH_${A.BUILD.ARCH} ${A.COMPILER.S.EXTRA_FLAGS} ${A.BUILD.EXTRA_FLAGS} ${A.INCLUDES}
|
||||||
@ -262,19 +301,34 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIP
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.SIZE.REGEX/value=^(?\:\\.text|\\.data|\\.bootloader)\\s+([0-9]+).*
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RECIPE.SIZE.REGEX/value=^(?\:\\.text|\\.data|\\.bootloader)\\s+([0-9]+).*
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.HARDWARE.PATH/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.HARDWARE.PATH/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.HARDWARE.PATH/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.HARDWARE.PATH/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.HARDWARE.PATH/value=/Applications/Arduino.app/Contents/Resources/Java/hardware
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.HARDWARE.PATH/value=/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/packages/arduino/hardware
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.IDE.PATH/delimiter=\:
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.IDE.PATH/operation=replace
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.IDE.PATH/value=/Applications/Arduino.app/Contents/Resources/Java
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.IDE.VERSION/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.IDE.VERSION/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.IDE.VERSION/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.IDE.VERSION/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.IDE.VERSION/value=10601
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.IDE.VERSION/value=10606
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.PLATFORM.PATH/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.PLATFORM.PATH/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.PLATFORM.PATH/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.PLATFORM.PATH/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.PLATFORM.PATH/value=/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/avr
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.PLATFORM.PATH/value=/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.14
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVR-GCC-4.9.2-ATMEL3.5.3-ARDUINO2.PATH/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVR-GCC-4.9.2-ATMEL3.5.3-ARDUINO2.PATH/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVR-GCC-4.9.2-ATMEL3.5.3-ARDUINO2.PATH/value=/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/tools/arduino/avr-gcc/4.9.2-atmel3.5.3-arduino2
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVR-GCC.PATH/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVR-GCC.PATH/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVR-GCC.PATH/value=/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/tools/arduino/avr-gcc/4.9.2-atmel3.5.3-arduino2
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVR-GCC4.9.2-ATMEL3.5.3-ARDUINO2.PATH/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVR-GCC4.9.2-ATMEL3.5.3-ARDUINO2.PATH/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVR-GCC4.9.2-ATMEL3.5.3-ARDUINO2.PATH/value=/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/tools/arduino/avr-gcc/4.9.2-atmel3.5.3-arduino2
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO6.PATH/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO6.PATH/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVRDUDE-6.3.0-ARDUINO6.PATH/value=/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/tools/arduino/avrdude/6.3.0-arduino6
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVRDUDE.PATH/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVRDUDE.PATH/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVRDUDE.PATH/value=/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/tools/arduino/avrdude/6.3.0-arduino6
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO6.PATH/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO6.PATH/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.RUNTIME.TOOLS.AVRDUDE6.3.0-ARDUINO6.PATH/value=/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/tools/arduino/avrdude/6.3.0-arduino6
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.SOFTWARE/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.SOFTWARE/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.SOFTWARE/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.SOFTWARE/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.SOFTWARE/value=ARDUINO
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.SOFTWARE/value=baeyens
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.BOOTLOADER.PARAMS.QUIET/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.BOOTLOADER.PARAMS.QUIET/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.BOOTLOADER.PARAMS.QUIET/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.BOOTLOADER.PARAMS.QUIET/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.BOOTLOADER.PARAMS.QUIET/value=-q -q
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.BOOTLOADER.PARAMS.QUIET/value=-q -q
|
||||||
@ -286,10 +340,10 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.BOOTLOADER.PATTERN/value="${A.CMD.PATH}" "-C${A.CONFIG.PATH}" ${A.BOOTLOADER.VERBOSE} -p${A.BUILD.MCU} -c${A.PROTOCOL} ${A.PROGRAM.EXTRA_PARAMS} "-Uflash\:w\:${A.RUNTIME.PLATFORM.PATH}/bootloaders/${A.BOOTLOADER.FILE}\:i" -Ulock\:w\:${A.BOOTLOADER.LOCK_BITS}\:m
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.BOOTLOADER.PATTERN/value="${A.CMD.PATH}" "-C${A.CONFIG.PATH}" ${A.BOOTLOADER.VERBOSE} -p${A.BUILD.MCU} -c${A.PROTOCOL} ${A.PROGRAM.EXTRA_PARAMS} "-Uflash\:w\:${A.RUNTIME.PLATFORM.PATH}/bootloaders/${A.BOOTLOADER.FILE}\:i" -Ulock\:w\:${A.BOOTLOADER.LOCK_BITS}\:m
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CMD.PATH/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CMD.PATH/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CMD.PATH/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CMD.PATH/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CMD.PATH/value=${A.RUNTIME.IDE.PATH}/hardware/tools/avr/bin/avrdude
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CMD.PATH/value=${A.PATH}/bin/avrdude
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CONFIG.PATH/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CONFIG.PATH/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CONFIG.PATH/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CONFIG.PATH/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CONFIG.PATH/value=${A.RUNTIME.IDE.PATH}/hardware/tools/avr/etc/avrdude.conf
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.CONFIG.PATH/value=${A.PATH}/etc/avrdude.conf
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PARAMS.QUIET/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PARAMS.QUIET/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PARAMS.QUIET/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PARAMS.QUIET/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PARAMS.QUIET/value=-q -q
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PARAMS.QUIET/value=-q -q
|
||||||
@ -299,6 +353,12 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PATTERN/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PATTERN/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PATTERN/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PATTERN/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PATTERN/value="${A.CMD.PATH}" "-C${A.CONFIG.PATH}" ${A.ERASE.VERBOSE} -p${A.BUILD.MCU} -c${A.PROTOCOL} ${A.PROGRAM.EXTRA_PARAMS} -e -Ulock\:w\:${A.BOOTLOADER.UNLOCK_BITS}\:m -Uefuse\:w\:${A.BOOTLOADER.EXTENDED_FUSES}\:m -Uhfuse\:w\:${A.BOOTLOADER.HIGH_FUSES}\:m -Ulfuse\:w\:${A.BOOTLOADER.LOW_FUSES}\:m
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.ERASE.PATTERN/value="${A.CMD.PATH}" "-C${A.CONFIG.PATH}" ${A.ERASE.VERBOSE} -p${A.BUILD.MCU} -c${A.PROTOCOL} ${A.PROGRAM.EXTRA_PARAMS} -e -Ulock\:w\:${A.BOOTLOADER.UNLOCK_BITS}\:m -Uefuse\:w\:${A.BOOTLOADER.EXTENDED_FUSES}\:m -Uhfuse\:w\:${A.BOOTLOADER.HIGH_FUSES}\:m -Ulfuse\:w\:${A.BOOTLOADER.LOW_FUSES}\:m
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PATH/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PATH/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PATH/value=${A.RUNTIME.TOOLS.AVRDUDE.PATH}
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.NOVERIFY/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.NOVERIFY/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.NOVERIFY/value=-V
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.QUIET/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.QUIET/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.QUIET/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.QUIET/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.QUIET/value=-q -q
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.QUIET/value=-q -q
|
||||||
@ -307,7 +367,10 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.VERBOSE/value=-v
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PARAMS.VERBOSE/value=-v
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PATTERN/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PATTERN/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PATTERN/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PATTERN/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PATTERN/value="${A.CMD.PATH}" "-C${A.CONFIG.PATH}" ${A.PROGRAM.VERBOSE} -p${A.BUILD.MCU} -c${A.PROTOCOL} ${A.PROGRAM.EXTRA_PARAMS} "-Uflash\:w\:${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.hex\:i"
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.PROGRAM.PATTERN/value="${A.CMD.PATH}" "-C${A.CONFIG.PATH}" ${A.PROGRAM.VERBOSE} ${A.PROGRAM.VERIFY} -p${A.BUILD.MCU} -c${A.PROTOCOL} ${A.PROGRAM.EXTRA_PARAMS} "-Uflash\:w\:${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.hex\:i"
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.NOVERIFY/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.NOVERIFY/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.NOVERIFY/value=-V
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.QUIET/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.QUIET/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.QUIET/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.QUIET/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.QUIET/value=-q -q
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.QUIET/value=-q -q
|
||||||
@ -316,7 +379,10 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.VERBOSE/value=-v
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PARAMS.VERBOSE/value=-v
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PATTERN/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PATTERN/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PATTERN/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PATTERN/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PATTERN/value="${A.CMD.PATH}" "-C${A.CONFIG.PATH}" ${A.UPLOAD.VERBOSE} -p${A.BUILD.MCU} -c${A.UPLOAD.PROTOCOL} -P${A.SERIAL.PORT} -b${A.UPLOAD.SPEED} -D "-Uflash\:w\:${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.hex\:i"
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE.UPLOAD.PATTERN/value="${A.TOOLS.AVRDUDE.CMD.PATH}" "-C${A.TOOLS.AVRDUDE.CONFIG.PATH}" ${A.UPLOAD.VERBOSE} ${A.UPLOAD.VERIFY} -p${A.BUILD.MCU} -c${A.UPLOAD.PROTOCOL} -P${A.SERIAL.PORT} -b${A.UPLOAD.SPEED} -D "-Uflash\:w\:${A.BUILD.PATH}/${A.BUILD.PROJECT_NAME}.hex\:i"
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE_REMOTE.UPLOAD.PATTERN/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE_REMOTE.UPLOAD.PATTERN/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.TOOLS.AVRDUDE_REMOTE.UPLOAD.PATTERN/value=/usr/bin/run-avrdude /tmp/sketch.hex ${A.UPLOAD.VERBOSE} -p${A.BUILD.MCU}
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.UPLOAD.MAXIMUM_DATA_SIZE/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.UPLOAD.MAXIMUM_DATA_SIZE/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.UPLOAD.MAXIMUM_DATA_SIZE/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.UPLOAD.MAXIMUM_DATA_SIZE/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.UPLOAD.MAXIMUM_DATA_SIZE/value=8192
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.UPLOAD.MAXIMUM_DATA_SIZE/value=8192
|
||||||
@ -334,13 +400,10 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.UPLOA
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.UPLOAD.TOOL/value=avrdude
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.UPLOAD.TOOL/value=avrdude
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VERSION/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VERSION/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VERSION/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VERSION/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VERSION/value=1.6.1
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VERSION/value=1.6.14
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.0/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.0/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.0/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.0/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.0/value=0x2341
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.0/value=0x2341
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.0X2A03.WARNING/delimiter=\:
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.0X2A03.WARNING/operation=replace
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.0X2A03.WARNING/value=Uncertified
|
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.1/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.1/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.1/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.1/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.1/value=0x2341
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.1/value=0x2341
|
||||||
@ -350,18 +413,24 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.2
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.3/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.3/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.3/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.3/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.3/value=0x2A03
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.3/value=0x2A03
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.4/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.4/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.4/value=0x2341
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.5/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.5/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/A.VID.5/value=0x2341
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.ARCHITECTURE_ID/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.ARCHITECTURE_ID/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.ARCHITECTURE_ID/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.ARCHITECTURE_ID/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.ARCHITECTURE_ID/value=avr
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.ARCHITECTURE_ID/value=avr
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARDS_FILE/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARDS_FILE/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARDS_FILE/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARDS_FILE/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARDS_FILE/value=/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/avr/boards.txt
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARDS_FILE/value=/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.14/boards.txt
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_ID/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_ID/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_ID/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_ID/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_ID/value=mega
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_ID/value=mega
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_NAME/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_NAME/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_NAME/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_NAME/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_NAME/value=Arduino Mega or Mega 2560
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BOARD_NAME/value=Arduino/Genuino Mega or Mega 2560
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BUILD_CORE/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BUILD_CORE/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BUILD_CORE/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BUILD_CORE/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BUILD_CORE/value=arduino
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.BUILD_CORE/value=arduino
|
||||||
@ -389,12 +458,15 @@ environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.
|
|||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.Keyboard\ Layout/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.Keyboard\ Layout/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.Keyboard\ Layout/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.Keyboard\ Layout/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.Keyboard\ Layout/value=
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.Keyboard\ Layout/value=
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PACKAGE.NAME/delimiter=\:
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PACKAGE.NAME/operation=replace
|
||||||
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PACKAGE.NAME/value=arduino
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PACKAGE_ID/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PACKAGE_ID/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PACKAGE_ID/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PACKAGE_ID/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PACKAGE_ID/value=arduino
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PACKAGE_ID/value=arduino
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PLATFORM_FILE/delimiter=\:
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PLATFORM_FILE/delimiter=\:
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PLATFORM_FILE/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PLATFORM_FILE/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PLATFORM_FILE/value=/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/avr/platform.txt
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PLATFORM_FILE/value=/opt/eclipse/eclipse-arduino/cpp-neon/eclipse/arduinoPlugin/packages/arduino/hardware/avr/1.6.14/platform.txt
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PROCESSOR/delimiter=;
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PROCESSOR/delimiter=;
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PROCESSOR/operation=replace
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PROCESSOR/operation=replace
|
||||||
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PROCESSOR/value=
|
environment/project/it.baeyens.arduino.core.toolChain.release.1898938335/JANTJE.PROCESSOR/value=
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "hmi.h"
|
#include "hmi.h"
|
||||||
#include "mqttClient.h"
|
#include "mqttclient.h"
|
||||||
|
|
||||||
Hmi hmi = Hmi();
|
Hmi hmi = Hmi();
|
||||||
Metro tick = Metro(25000); // 25s
|
Metro tick = Metro(25000); // 25s
|
||||||
|
201
SPI/SPI.cpp
Normal file
201
SPI/SPI.cpp
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010 by Cristian Maglie <c.maglie@arduino.cc>
|
||||||
|
* Copyright (c) 2014 by Paul Stoffregen <paul@pjrc.com> (Transaction API)
|
||||||
|
* Copyright (c) 2014 by Matthijs Kooijman <matthijs@stdin.nl> (SPISettings AVR)
|
||||||
|
* Copyright (c) 2014 by Andrew J. Kroll <xxxajk@gmail.com> (atomicity fixes)
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
SPIClass SPI;
|
||||||
|
|
||||||
|
uint8_t SPIClass::initialized = 0;
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
noInterrupts(); // Protect from a scheduler and prevent transactionBegin
|
||||||
|
if (!initialized) {
|
||||||
|
// Set SS to high so a connected chip will be "deselected" by default
|
||||||
|
uint8_t port = digitalPinToPort(SS);
|
||||||
|
uint8_t bit = digitalPinToBitMask(SS);
|
||||||
|
volatile uint8_t *reg = portModeRegister(port);
|
||||||
|
|
||||||
|
// if the SS pin is not already configured as an output
|
||||||
|
// then set it high (to enable the internal pull-up resistor)
|
||||||
|
if(!(*reg & bit)){
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
initialized++; // reference count
|
||||||
|
SREG = sreg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPIClass::end() {
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
noInterrupts(); // Protect from a scheduler and prevent transactionBegin
|
||||||
|
// Decrease the reference counter
|
||||||
|
if (initialized)
|
||||||
|
initialized--;
|
||||||
|
// If there are no more references disable SPI
|
||||||
|
if (!initialized) {
|
||||||
|
SPCR &= ~_BV(SPE);
|
||||||
|
interruptMode = 0;
|
||||||
|
#ifdef SPI_TRANSACTION_MISMATCH_LED
|
||||||
|
inTransactionFlag = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
SREG = sreg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 mask = 0;
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
noInterrupts(); // Protect from a scheduler and prevent transactionBegin
|
||||||
|
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;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
interruptMask |= mask;
|
||||||
|
if (!interruptMode)
|
||||||
|
interruptMode = 1;
|
||||||
|
SREG = sreg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPIClass::notUsingInterrupt(uint8_t interruptNumber)
|
||||||
|
{
|
||||||
|
// Once in mode 2 we can't go back to 0 without a proper reference count
|
||||||
|
if (interruptMode == 2)
|
||||||
|
return;
|
||||||
|
uint8_t mask = 0;
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
noInterrupts(); // Protect from a scheduler and prevent transactionBegin
|
||||||
|
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:
|
||||||
|
break;
|
||||||
|
// this case can't be reached
|
||||||
|
}
|
||||||
|
interruptMask &= ~mask;
|
||||||
|
if (!interruptMask)
|
||||||
|
interruptMode = 0;
|
||||||
|
SREG = sreg;
|
||||||
|
}
|
324
SPI/SPI.h
Normal file
324
SPI/SPI.h
Normal file
@ -0,0 +1,324 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010 by Cristian Maglie <c.maglie@arduino.cc>
|
||||||
|
* Copyright (c) 2014 by Paul Stoffregen <paul@pjrc.com> (Transaction API)
|
||||||
|
* Copyright (c) 2014 by Matthijs Kooijman <matthijs@stdin.nl> (SPISettings AVR)
|
||||||
|
* Copyright (c) 2014 by Andrew J. Kroll <xxxajk@gmail.com> (atomicity fixes)
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SPI_H_INCLUDED
|
||||||
|
#define _SPI_H_INCLUDED
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
// SPI_HAS_TRANSACTION means SPI has beginTransaction(), endTransaction(),
|
||||||
|
// usingInterrupt(), and SPISetting(clock, bitOrder, dataMode)
|
||||||
|
#define SPI_HAS_TRANSACTION 1
|
||||||
|
|
||||||
|
// SPI_HAS_NOTUSINGINTERRUPT means that SPI has notUsingInterrupt() method
|
||||||
|
#define SPI_HAS_NOTUSINGINTERRUPT 1
|
||||||
|
|
||||||
|
// SPI_ATOMIC_VERSION means that SPI has atomicity fixes and what version.
|
||||||
|
// This way when there is a bug fix you can check this define to alert users
|
||||||
|
// of your code if it uses better version of this library.
|
||||||
|
// This also implies everything that SPI_HAS_TRANSACTION as documented above is
|
||||||
|
// available too.
|
||||||
|
#define SPI_ATOMIC_VERSION 1
|
||||||
|
|
||||||
|
// Uncomment this line to add detection of mismatched begin/end transactions.
|
||||||
|
// A mismatch occurs if other libraries fail to use SPI.endTransaction() for
|
||||||
|
// each SPI.beginTransaction(). Connect an LED to this pin. The LED will turn
|
||||||
|
// on if any mismatch is ever detected.
|
||||||
|
//#define SPI_TRANSACTION_MISMATCH_LED 5
|
||||||
|
|
||||||
|
#ifndef LSBFIRST
|
||||||
|
#define LSBFIRST 0
|
||||||
|
#endif
|
||||||
|
#ifndef MSBFIRST
|
||||||
|
#define MSBFIRST 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SPI_CLOCK_DIV4 0x00
|
||||||
|
#define SPI_CLOCK_DIV16 0x01
|
||||||
|
#define SPI_CLOCK_DIV64 0x02
|
||||||
|
#define SPI_CLOCK_DIV128 0x03
|
||||||
|
#define SPI_CLOCK_DIV2 0x04
|
||||||
|
#define SPI_CLOCK_DIV8 0x05
|
||||||
|
#define SPI_CLOCK_DIV32 0x06
|
||||||
|
|
||||||
|
#define SPI_MODE0 0x00
|
||||||
|
#define SPI_MODE1 0x04
|
||||||
|
#define SPI_MODE2 0x08
|
||||||
|
#define SPI_MODE3 0x0C
|
||||||
|
|
||||||
|
#define SPI_MODE_MASK 0x0C // CPOL = bit 3, CPHA = bit 2 on SPCR
|
||||||
|
#define SPI_CLOCK_MASK 0x03 // SPR1 = bit 1, SPR0 = bit 0 on SPCR
|
||||||
|
#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR
|
||||||
|
|
||||||
|
// define SPI_AVR_EIMSK for AVR boards with external interrupt pins
|
||||||
|
#if defined(EIMSK)
|
||||||
|
#define SPI_AVR_EIMSK EIMSK
|
||||||
|
#elif defined(GICR)
|
||||||
|
#define SPI_AVR_EIMSK GICR
|
||||||
|
#elif defined(GIMSK)
|
||||||
|
#define SPI_AVR_EIMSK GIMSK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class SPISettings {
|
||||||
|
public:
|
||||||
|
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {
|
||||||
|
if (__builtin_constant_p(clock)) {
|
||||||
|
init_AlwaysInline(clock, bitOrder, dataMode);
|
||||||
|
} else {
|
||||||
|
init_MightInline(clock, bitOrder, dataMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SPISettings() {
|
||||||
|
init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
void init_MightInline(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {
|
||||||
|
init_AlwaysInline(clock, bitOrder, dataMode);
|
||||||
|
}
|
||||||
|
void init_AlwaysInline(uint32_t clock, uint8_t bitOrder, uint8_t dataMode)
|
||||||
|
__attribute__((__always_inline__)) {
|
||||||
|
// Clock settings are defined as follows. Note that this shows SPI2X
|
||||||
|
// inverted, so the bits form increasing numbers. Also note that
|
||||||
|
// fosc/64 appears twice
|
||||||
|
// SPR1 SPR0 ~SPI2X Freq
|
||||||
|
// 0 0 0 fosc/2
|
||||||
|
// 0 0 1 fosc/4
|
||||||
|
// 0 1 0 fosc/8
|
||||||
|
// 0 1 1 fosc/16
|
||||||
|
// 1 0 0 fosc/32
|
||||||
|
// 1 0 1 fosc/64
|
||||||
|
// 1 1 0 fosc/64
|
||||||
|
// 1 1 1 fosc/128
|
||||||
|
|
||||||
|
// We find the fastest clock that is less than or equal to the
|
||||||
|
// given clock rate. The clock divider that results in clock_setting
|
||||||
|
// is 2 ^^ (clock_div + 1). If nothing is slow enough, we'll use the
|
||||||
|
// slowest (128 == 2 ^^ 7, so clock_div = 6).
|
||||||
|
uint8_t clockDiv;
|
||||||
|
|
||||||
|
// When the clock is known at compiletime, use this if-then-else
|
||||||
|
// cascade, which the compiler knows how to completely optimize
|
||||||
|
// away. When clock is not known, use a loop instead, which generates
|
||||||
|
// shorter code.
|
||||||
|
if (__builtin_constant_p(clock)) {
|
||||||
|
if (clock >= F_CPU / 2) {
|
||||||
|
clockDiv = 0;
|
||||||
|
} else if (clock >= F_CPU / 4) {
|
||||||
|
clockDiv = 1;
|
||||||
|
} else if (clock >= F_CPU / 8) {
|
||||||
|
clockDiv = 2;
|
||||||
|
} else if (clock >= F_CPU / 16) {
|
||||||
|
clockDiv = 3;
|
||||||
|
} else if (clock >= F_CPU / 32) {
|
||||||
|
clockDiv = 4;
|
||||||
|
} else if (clock >= F_CPU / 64) {
|
||||||
|
clockDiv = 5;
|
||||||
|
} else {
|
||||||
|
clockDiv = 6;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uint32_t clockSetting = F_CPU / 2;
|
||||||
|
clockDiv = 0;
|
||||||
|
while (clockDiv < 6 && clock < clockSetting) {
|
||||||
|
clockSetting /= 2;
|
||||||
|
clockDiv++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compensate for the duplicate fosc/64
|
||||||
|
if (clockDiv == 6)
|
||||||
|
clockDiv = 7;
|
||||||
|
|
||||||
|
// Invert the SPI2X bit
|
||||||
|
clockDiv ^= 0x1;
|
||||||
|
|
||||||
|
// Pack into the SPISettings class
|
||||||
|
spcr = _BV(SPE) | _BV(MSTR) | ((bitOrder == LSBFIRST) ? _BV(DORD) : 0) |
|
||||||
|
(dataMode & SPI_MODE_MASK) | ((clockDiv >> 1) & SPI_CLOCK_MASK);
|
||||||
|
spsr = clockDiv & SPI_2XCLOCK_MASK;
|
||||||
|
}
|
||||||
|
uint8_t spcr;
|
||||||
|
uint8_t spsr;
|
||||||
|
friend class SPIClass;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SPIClass {
|
||||||
|
public:
|
||||||
|
// Initialize the SPI library
|
||||||
|
static void begin();
|
||||||
|
|
||||||
|
// If SPI is used from within an interrupt, this function registers
|
||||||
|
// that interrupt with the SPI library, so beginTransaction() can
|
||||||
|
// prevent conflicts. The input interruptNumber is the number used
|
||||||
|
// with attachInterrupt. If SPI is used from a different interrupt
|
||||||
|
// (eg, a timer), interruptNumber should be 255.
|
||||||
|
static void usingInterrupt(uint8_t interruptNumber);
|
||||||
|
// And this does the opposite.
|
||||||
|
static void notUsingInterrupt(uint8_t interruptNumber);
|
||||||
|
// Note: the usingInterrupt and notUsingInterrupt functions should
|
||||||
|
// not to be called from ISR context or inside a transaction.
|
||||||
|
// For details see:
|
||||||
|
// https://github.com/arduino/Arduino/pull/2381
|
||||||
|
// https://github.com/arduino/Arduino/pull/2449
|
||||||
|
|
||||||
|
// Before using SPI.transfer() or asserting chip select pins,
|
||||||
|
// this function is used to gain exclusive access to the SPI bus
|
||||||
|
// and configure the correct settings.
|
||||||
|
inline static void beginTransaction(SPISettings settings) {
|
||||||
|
if (interruptMode > 0) {
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
noInterrupts();
|
||||||
|
|
||||||
|
#ifdef SPI_AVR_EIMSK
|
||||||
|
if (interruptMode == 1) {
|
||||||
|
interruptSave = SPI_AVR_EIMSK;
|
||||||
|
SPI_AVR_EIMSK &= ~interruptMask;
|
||||||
|
SREG = sreg;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
interruptSave = sreg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SPI_TRANSACTION_MISMATCH_LED
|
||||||
|
if (inTransactionFlag) {
|
||||||
|
pinMode(SPI_TRANSACTION_MISMATCH_LED, OUTPUT);
|
||||||
|
digitalWrite(SPI_TRANSACTION_MISMATCH_LED, HIGH);
|
||||||
|
}
|
||||||
|
inTransactionFlag = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SPCR = settings.spcr;
|
||||||
|
SPSR = settings.spsr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write to the SPI bus (MOSI pin) and also receive (MISO pin)
|
||||||
|
inline static uint8_t transfer(uint8_t data) {
|
||||||
|
SPDR = data;
|
||||||
|
/*
|
||||||
|
* The following NOP introduces a small delay that can prevent the wait
|
||||||
|
* loop form iterating when running at the maximum speed. This gives
|
||||||
|
* about 10% more speed, even if it seems counter-intuitive. At lower
|
||||||
|
* speeds it is unnoticed.
|
||||||
|
*/
|
||||||
|
asm volatile("nop");
|
||||||
|
while (!(SPSR & _BV(SPIF))) ; // wait
|
||||||
|
return SPDR;
|
||||||
|
}
|
||||||
|
inline static uint16_t transfer16(uint16_t data) {
|
||||||
|
union { uint16_t val; struct { uint8_t lsb; uint8_t msb; }; } in, out;
|
||||||
|
in.val = data;
|
||||||
|
if (!(SPCR & _BV(DORD))) {
|
||||||
|
SPDR = in.msb;
|
||||||
|
asm volatile("nop"); // See transfer(uint8_t) function
|
||||||
|
while (!(SPSR & _BV(SPIF))) ;
|
||||||
|
out.msb = SPDR;
|
||||||
|
SPDR = in.lsb;
|
||||||
|
asm volatile("nop");
|
||||||
|
while (!(SPSR & _BV(SPIF))) ;
|
||||||
|
out.lsb = SPDR;
|
||||||
|
} else {
|
||||||
|
SPDR = in.lsb;
|
||||||
|
asm volatile("nop");
|
||||||
|
while (!(SPSR & _BV(SPIF))) ;
|
||||||
|
out.lsb = SPDR;
|
||||||
|
SPDR = in.msb;
|
||||||
|
asm volatile("nop");
|
||||||
|
while (!(SPSR & _BV(SPIF))) ;
|
||||||
|
out.msb = SPDR;
|
||||||
|
}
|
||||||
|
return out.val;
|
||||||
|
}
|
||||||
|
inline static void transfer(void *buf, size_t count) {
|
||||||
|
if (count == 0) return;
|
||||||
|
uint8_t *p = (uint8_t *)buf;
|
||||||
|
SPDR = *p;
|
||||||
|
while (--count > 0) {
|
||||||
|
uint8_t out = *(p + 1);
|
||||||
|
while (!(SPSR & _BV(SPIF))) ;
|
||||||
|
uint8_t in = SPDR;
|
||||||
|
SPDR = out;
|
||||||
|
*p++ = in;
|
||||||
|
}
|
||||||
|
while (!(SPSR & _BV(SPIF))) ;
|
||||||
|
*p = SPDR;
|
||||||
|
}
|
||||||
|
// After performing a group of transfers and releasing the chip select
|
||||||
|
// signal, this function allows others to access the SPI bus
|
||||||
|
inline static void endTransaction(void) {
|
||||||
|
#ifdef SPI_TRANSACTION_MISMATCH_LED
|
||||||
|
if (!inTransactionFlag) {
|
||||||
|
pinMode(SPI_TRANSACTION_MISMATCH_LED, OUTPUT);
|
||||||
|
digitalWrite(SPI_TRANSACTION_MISMATCH_LED, HIGH);
|
||||||
|
}
|
||||||
|
inTransactionFlag = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (interruptMode > 0) {
|
||||||
|
#ifdef SPI_AVR_EIMSK
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
#endif
|
||||||
|
noInterrupts();
|
||||||
|
#ifdef SPI_AVR_EIMSK
|
||||||
|
if (interruptMode == 1) {
|
||||||
|
SPI_AVR_EIMSK = interruptSave;
|
||||||
|
SREG = sreg;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
SREG = interruptSave;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable the SPI bus
|
||||||
|
static void end();
|
||||||
|
|
||||||
|
// This function is deprecated. New applications should use
|
||||||
|
// beginTransaction() to configure SPI settings.
|
||||||
|
inline static void setBitOrder(uint8_t bitOrder) {
|
||||||
|
if (bitOrder == LSBFIRST) SPCR |= _BV(DORD);
|
||||||
|
else SPCR &= ~(_BV(DORD));
|
||||||
|
}
|
||||||
|
// This function is deprecated. New applications should use
|
||||||
|
// beginTransaction() to configure SPI settings.
|
||||||
|
inline static void setDataMode(uint8_t dataMode) {
|
||||||
|
SPCR = (SPCR & ~SPI_MODE_MASK) | dataMode;
|
||||||
|
}
|
||||||
|
// This function is deprecated. New applications should use
|
||||||
|
// beginTransaction() to configure SPI settings.
|
||||||
|
inline static void setClockDivider(uint8_t clockDiv) {
|
||||||
|
SPCR = (SPCR & ~SPI_CLOCK_MASK) | (clockDiv & SPI_CLOCK_MASK);
|
||||||
|
SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | ((clockDiv >> 2) & SPI_2XCLOCK_MASK);
|
||||||
|
}
|
||||||
|
// These undocumented functions should not be used. SPI.transfer()
|
||||||
|
// polls the hardware flag which is automatically cleared as the
|
||||||
|
// AVR responds to SPI's interrupt
|
||||||
|
inline static void attachInterrupt() { SPCR |= _BV(SPIE); }
|
||||||
|
inline static void detachInterrupt() { SPCR &= ~_BV(SPIE); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
static uint8_t initialized;
|
||||||
|
static uint8_t interruptMode; // 0=none, 1=mask, 2=global
|
||||||
|
static uint8_t interruptMask; // which interrupts to mask
|
||||||
|
static uint8_t interruptSave; // temp storage, to restore state
|
||||||
|
#ifdef SPI_TRANSACTION_MISMATCH_LED
|
||||||
|
static uint8_t inTransactionFlag;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
extern SPIClass SPI;
|
||||||
|
|
||||||
|
#endif
|
248
WiFi/WiFi.cpp
Normal file
248
WiFi/WiFi.cpp
Normal file
@ -0,0 +1,248 @@
|
|||||||
|
/*
|
||||||
|
WiFi.cpp - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino LLC. 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "utility/wifi_drv.h"
|
||||||
|
#include "WiFi.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "utility/wl_definitions.h"
|
||||||
|
#include "utility/wl_types.h"
|
||||||
|
#include "utility/debug.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
// XXX: don't make assumptions about the value of MAX_SOCK_NUM.
|
||||||
|
int16_t WiFiClass::_state[MAX_SOCK_NUM] = { NA_STATE, NA_STATE, NA_STATE, NA_STATE };
|
||||||
|
uint16_t WiFiClass::_server_port[MAX_SOCK_NUM] = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
WiFiClass::WiFiClass()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiClass::init()
|
||||||
|
{
|
||||||
|
WiFiDrv::wifiDriverInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiClass::getSocket()
|
||||||
|
{
|
||||||
|
for (uint8_t i = 0; i < MAX_SOCK_NUM; ++i)
|
||||||
|
{
|
||||||
|
if (WiFiClass::_server_port[i] == 0)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NO_SOCKET_AVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* WiFiClass::firmwareVersion()
|
||||||
|
{
|
||||||
|
return WiFiDrv::getFwVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiClass::begin(char* ssid)
|
||||||
|
{
|
||||||
|
uint8_t status = WL_IDLE_STATUS;
|
||||||
|
uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;
|
||||||
|
|
||||||
|
if (WiFiDrv::wifiSetNetwork(ssid, strlen(ssid)) != WL_FAILURE)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
delay(WL_DELAY_START_CONNECTION);
|
||||||
|
status = WiFiDrv::getConnectionStatus();
|
||||||
|
}
|
||||||
|
while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
status = WL_CONNECT_FAILED;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiClass::begin(char* ssid, uint8_t key_idx, const char *key)
|
||||||
|
{
|
||||||
|
uint8_t status = WL_IDLE_STATUS;
|
||||||
|
uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;
|
||||||
|
|
||||||
|
// set encryption key
|
||||||
|
if (WiFiDrv::wifiSetKey(ssid, strlen(ssid), key_idx, key, strlen(key)) != WL_FAILURE)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
delay(WL_DELAY_START_CONNECTION);
|
||||||
|
status = WiFiDrv::getConnectionStatus();
|
||||||
|
}while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
|
||||||
|
}else{
|
||||||
|
status = WL_CONNECT_FAILED;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiClass::begin(char* ssid, const char *passphrase)
|
||||||
|
{
|
||||||
|
uint8_t status = WL_IDLE_STATUS;
|
||||||
|
uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;
|
||||||
|
|
||||||
|
// set passphrase
|
||||||
|
if (WiFiDrv::wifiSetPassphrase(ssid, strlen(ssid), passphrase, strlen(passphrase))!= WL_FAILURE)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
delay(WL_DELAY_START_CONNECTION);
|
||||||
|
status = WiFiDrv::getConnectionStatus();
|
||||||
|
}
|
||||||
|
while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
|
||||||
|
}else{
|
||||||
|
status = WL_CONNECT_FAILED;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiClass::config(IPAddress local_ip)
|
||||||
|
{
|
||||||
|
WiFiDrv::config(1, (uint32_t)local_ip, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiClass::config(IPAddress local_ip, IPAddress dns_server)
|
||||||
|
{
|
||||||
|
WiFiDrv::config(1, (uint32_t)local_ip, 0, 0);
|
||||||
|
WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway)
|
||||||
|
{
|
||||||
|
WiFiDrv::config(2, (uint32_t)local_ip, (uint32_t)gateway, 0);
|
||||||
|
WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
|
||||||
|
{
|
||||||
|
WiFiDrv::config(3, (uint32_t)local_ip, (uint32_t)gateway, (uint32_t)subnet);
|
||||||
|
WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiClass::setDNS(IPAddress dns_server1)
|
||||||
|
{
|
||||||
|
WiFiDrv::setDNS(1, (uint32_t)dns_server1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiClass::setDNS(IPAddress dns_server1, IPAddress dns_server2)
|
||||||
|
{
|
||||||
|
WiFiDrv::setDNS(2, (uint32_t)dns_server1, (uint32_t)dns_server2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiClass::disconnect()
|
||||||
|
{
|
||||||
|
return WiFiDrv::disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* WiFiClass::macAddress(uint8_t* mac)
|
||||||
|
{
|
||||||
|
uint8_t* _mac = WiFiDrv::getMacAddress();
|
||||||
|
memcpy(mac, _mac, WL_MAC_ADDR_LENGTH);
|
||||||
|
return mac;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress WiFiClass::localIP()
|
||||||
|
{
|
||||||
|
IPAddress ret;
|
||||||
|
WiFiDrv::getIpAddress(ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress WiFiClass::subnetMask()
|
||||||
|
{
|
||||||
|
IPAddress ret;
|
||||||
|
WiFiDrv::getSubnetMask(ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress WiFiClass::gatewayIP()
|
||||||
|
{
|
||||||
|
IPAddress ret;
|
||||||
|
WiFiDrv::getGatewayIP(ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* WiFiClass::SSID()
|
||||||
|
{
|
||||||
|
return WiFiDrv::getCurrentSSID();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* WiFiClass::BSSID(uint8_t* bssid)
|
||||||
|
{
|
||||||
|
uint8_t* _bssid = WiFiDrv::getCurrentBSSID();
|
||||||
|
memcpy(bssid, _bssid, WL_MAC_ADDR_LENGTH);
|
||||||
|
return bssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t WiFiClass::RSSI()
|
||||||
|
{
|
||||||
|
return WiFiDrv::getCurrentRSSI();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiClass::encryptionType()
|
||||||
|
{
|
||||||
|
return WiFiDrv::getCurrentEncryptionType();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int8_t WiFiClass::scanNetworks()
|
||||||
|
{
|
||||||
|
uint8_t attempts = 10;
|
||||||
|
uint8_t numOfNetworks = 0;
|
||||||
|
|
||||||
|
if (WiFiDrv::startScanNetworks() == WL_FAILURE)
|
||||||
|
return WL_FAILURE;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
delay(2000);
|
||||||
|
numOfNetworks = WiFiDrv::getScanNetworks();
|
||||||
|
}
|
||||||
|
while (( numOfNetworks == 0)&&(--attempts>0));
|
||||||
|
return numOfNetworks;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* WiFiClass::SSID(uint8_t networkItem)
|
||||||
|
{
|
||||||
|
return WiFiDrv::getSSIDNetoworks(networkItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t WiFiClass::RSSI(uint8_t networkItem)
|
||||||
|
{
|
||||||
|
return WiFiDrv::getRSSINetoworks(networkItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiClass::encryptionType(uint8_t networkItem)
|
||||||
|
{
|
||||||
|
return WiFiDrv::getEncTypeNetowrks(networkItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiClass::status()
|
||||||
|
{
|
||||||
|
return WiFiDrv::getConnectionStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiClass::hostByName(const char* aHostname, IPAddress& aResult)
|
||||||
|
{
|
||||||
|
return WiFiDrv::getHostByName(aHostname, aResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFiClass WiFi;
|
246
WiFi/WiFi.h
Normal file
246
WiFi/WiFi.h
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
/*
|
||||||
|
WiFi.h - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino LLC. 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 WiFi_h
|
||||||
|
#define WiFi_h
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "utility/wl_definitions.h"
|
||||||
|
#include "utility/wl_types.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "IPAddress.h"
|
||||||
|
#include "WiFiClient.h"
|
||||||
|
#include "WiFiServer.h"
|
||||||
|
|
||||||
|
class WiFiClass
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
static void init();
|
||||||
|
public:
|
||||||
|
static int16_t _state[MAX_SOCK_NUM];
|
||||||
|
static uint16_t _server_port[MAX_SOCK_NUM];
|
||||||
|
|
||||||
|
WiFiClass();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the first socket available
|
||||||
|
*/
|
||||||
|
static uint8_t getSocket();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get firmware version
|
||||||
|
*/
|
||||||
|
static char* firmwareVersion();
|
||||||
|
|
||||||
|
|
||||||
|
/* Start Wifi connection for OPEN networks
|
||||||
|
*
|
||||||
|
* param ssid: Pointer to the SSID string.
|
||||||
|
*/
|
||||||
|
int begin(char* ssid);
|
||||||
|
|
||||||
|
/* Start Wifi connection with WEP encryption.
|
||||||
|
* Configure a key into the device. The key type (WEP-40, WEP-104)
|
||||||
|
* is determined by the size of the key (5 bytes for WEP-40, 13 bytes for WEP-104).
|
||||||
|
*
|
||||||
|
* param ssid: Pointer to the SSID string.
|
||||||
|
* param key_idx: The key index to set. Valid values are 0-3.
|
||||||
|
* param key: Key input buffer.
|
||||||
|
*/
|
||||||
|
int begin(char* ssid, uint8_t key_idx, const char* key);
|
||||||
|
|
||||||
|
/* Start Wifi connection with passphrase
|
||||||
|
* the most secure supported mode will be automatically selected
|
||||||
|
*
|
||||||
|
* param ssid: Pointer to the SSID string.
|
||||||
|
* param passphrase: Passphrase. Valid characters in a passphrase
|
||||||
|
* must be between ASCII 32-126 (decimal).
|
||||||
|
*/
|
||||||
|
int begin(char* ssid, const char *passphrase);
|
||||||
|
|
||||||
|
/* Change Ip configuration settings disabling the dhcp client
|
||||||
|
*
|
||||||
|
* param local_ip: Static ip configuration
|
||||||
|
*/
|
||||||
|
void config(IPAddress local_ip);
|
||||||
|
|
||||||
|
/* Change Ip configuration settings disabling the dhcp client
|
||||||
|
*
|
||||||
|
* param local_ip: Static ip configuration
|
||||||
|
* param dns_server: IP configuration for DNS server 1
|
||||||
|
*/
|
||||||
|
void config(IPAddress local_ip, IPAddress dns_server);
|
||||||
|
|
||||||
|
/* Change Ip configuration settings disabling the dhcp client
|
||||||
|
*
|
||||||
|
* param local_ip: Static ip configuration
|
||||||
|
* param dns_server: IP configuration for DNS server 1
|
||||||
|
* param gateway : Static gateway configuration
|
||||||
|
*/
|
||||||
|
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
|
||||||
|
|
||||||
|
/* Change Ip configuration settings disabling the dhcp client
|
||||||
|
*
|
||||||
|
* param local_ip: Static ip configuration
|
||||||
|
* param dns_server: IP configuration for DNS server 1
|
||||||
|
* param gateway: Static gateway configuration
|
||||||
|
* param subnet: Static Subnet mask
|
||||||
|
*/
|
||||||
|
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);
|
||||||
|
|
||||||
|
/* Change DNS Ip configuration
|
||||||
|
*
|
||||||
|
* param dns_server1: ip configuration for DNS server 1
|
||||||
|
*/
|
||||||
|
void setDNS(IPAddress dns_server1);
|
||||||
|
|
||||||
|
/* Change DNS Ip configuration
|
||||||
|
*
|
||||||
|
* param dns_server1: ip configuration for DNS server 1
|
||||||
|
* param dns_server2: ip configuration for DNS server 2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void setDNS(IPAddress dns_server1, IPAddress dns_server2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Disconnect from the network
|
||||||
|
*
|
||||||
|
* return: one value of wl_status_t enum
|
||||||
|
*/
|
||||||
|
int disconnect(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the interface MAC address.
|
||||||
|
*
|
||||||
|
* return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
|
||||||
|
*/
|
||||||
|
uint8_t* macAddress(uint8_t* mac);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the interface IP address.
|
||||||
|
*
|
||||||
|
* return: Ip address value
|
||||||
|
*/
|
||||||
|
IPAddress localIP();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the interface subnet mask address.
|
||||||
|
*
|
||||||
|
* return: subnet mask address value
|
||||||
|
*/
|
||||||
|
IPAddress subnetMask();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the gateway ip address.
|
||||||
|
*
|
||||||
|
* return: gateway ip address value
|
||||||
|
*/
|
||||||
|
IPAddress gatewayIP();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the current SSID associated with the network
|
||||||
|
*
|
||||||
|
* return: ssid string
|
||||||
|
*/
|
||||||
|
char* SSID();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the current BSSID associated with the network.
|
||||||
|
* It is the MAC address of the Access Point
|
||||||
|
*
|
||||||
|
* return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
|
||||||
|
*/
|
||||||
|
uint8_t* BSSID(uint8_t* bssid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the current RSSI /Received Signal Strength in dBm)
|
||||||
|
* associated with the network
|
||||||
|
*
|
||||||
|
* return: signed value
|
||||||
|
*/
|
||||||
|
int32_t RSSI();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the Encryption Type associated with the network
|
||||||
|
*
|
||||||
|
* return: one value of wl_enc_type enum
|
||||||
|
*/
|
||||||
|
uint8_t encryptionType();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Start scan WiFi networks available
|
||||||
|
*
|
||||||
|
* return: Number of discovered networks
|
||||||
|
*/
|
||||||
|
int8_t scanNetworks();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the SSID discovered during the network scan.
|
||||||
|
*
|
||||||
|
* param networkItem: specify from which network item want to get the information
|
||||||
|
*
|
||||||
|
* return: ssid string of the specified item on the networks scanned list
|
||||||
|
*/
|
||||||
|
char* SSID(uint8_t networkItem);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the encryption type of the networks discovered during the scanNetworks
|
||||||
|
*
|
||||||
|
* param networkItem: specify from which network item want to get the information
|
||||||
|
*
|
||||||
|
* return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
|
||||||
|
*/
|
||||||
|
uint8_t encryptionType(uint8_t networkItem);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the RSSI of the networks discovered during the scanNetworks
|
||||||
|
*
|
||||||
|
* param networkItem: specify from which network item want to get the information
|
||||||
|
*
|
||||||
|
* return: signed value of RSSI of the specified item on the networks scanned list
|
||||||
|
*/
|
||||||
|
int32_t RSSI(uint8_t networkItem);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return Connection status.
|
||||||
|
*
|
||||||
|
* return: one of the value defined in wl_status_t
|
||||||
|
*/
|
||||||
|
uint8_t status();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 hostByName(const char* aHostname, IPAddress& aResult);
|
||||||
|
|
||||||
|
friend class WiFiClient;
|
||||||
|
friend class WiFiServer;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern WiFiClass WiFi;
|
||||||
|
|
||||||
|
#endif
|
200
WiFi/WiFiClient.cpp
Normal file
200
WiFi/WiFiClient.cpp
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
/*
|
||||||
|
WiFiClient.cpp - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino LLC. 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "utility/wl_definitions.h"
|
||||||
|
#include "utility/wl_types.h"
|
||||||
|
#include "string.h"
|
||||||
|
#include "utility/debug.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "WiFi.h"
|
||||||
|
#include "WiFiClient.h"
|
||||||
|
#include "WiFiServer.h"
|
||||||
|
#include "utility/server_drv.h"
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t WiFiClient::_srcport = 1024;
|
||||||
|
|
||||||
|
WiFiClient::WiFiClient() : _sock(MAX_SOCK_NUM) {
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFiClient::WiFiClient(uint8_t sock) : _sock(sock) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiClient::connect(const char* host, uint16_t port) {
|
||||||
|
IPAddress remote_addr;
|
||||||
|
if (WiFi.hostByName(host, remote_addr))
|
||||||
|
{
|
||||||
|
return connect(remote_addr, port);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiClient::connect(IPAddress ip, uint16_t port) {
|
||||||
|
_sock = getFirstSocket();
|
||||||
|
if (_sock != NO_SOCKET_AVAIL)
|
||||||
|
{
|
||||||
|
ServerDrv::startClient(uint32_t(ip), port, _sock);
|
||||||
|
WiFiClass::_state[_sock] = _sock;
|
||||||
|
|
||||||
|
unsigned long start = millis();
|
||||||
|
|
||||||
|
// wait 4 second for the connection to close
|
||||||
|
while (!connected() && millis() - start < 10000)
|
||||||
|
delay(1);
|
||||||
|
|
||||||
|
if (!connected())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Serial.println("No Socket available");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t WiFiClient::write(uint8_t b) {
|
||||||
|
return write(&b, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t WiFiClient::write(const uint8_t *buf, size_t size) {
|
||||||
|
if (_sock >= MAX_SOCK_NUM)
|
||||||
|
{
|
||||||
|
setWriteError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (size==0)
|
||||||
|
{
|
||||||
|
setWriteError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!ServerDrv::sendData(_sock, buf, size))
|
||||||
|
{
|
||||||
|
setWriteError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!ServerDrv::checkDataSent(_sock))
|
||||||
|
{
|
||||||
|
setWriteError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiClient::available() {
|
||||||
|
if (_sock != 255)
|
||||||
|
{
|
||||||
|
return ServerDrv::availData(_sock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiClient::read() {
|
||||||
|
uint8_t b;
|
||||||
|
if (!available())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ServerDrv::getData(_sock, &b);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WiFiClient::read(uint8_t* buf, size_t size) {
|
||||||
|
// sizeof(size_t) is architecture dependent
|
||||||
|
// but we need a 16 bit data type here
|
||||||
|
uint16_t _size = size;
|
||||||
|
if (!ServerDrv::getDataBuf(_sock, buf, &_size))
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiClient::peek() {
|
||||||
|
uint8_t b;
|
||||||
|
if (!available())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ServerDrv::getData(_sock, &b, 1);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiClient::flush() {
|
||||||
|
while (available())
|
||||||
|
read();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiClient::stop() {
|
||||||
|
|
||||||
|
if (_sock == 255)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ServerDrv::stopClient(_sock);
|
||||||
|
WiFiClass::_state[_sock] = NA_STATE;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
// wait maximum 5 secs for the connection to close
|
||||||
|
while (status() != CLOSED && ++count < 50)
|
||||||
|
delay(100);
|
||||||
|
|
||||||
|
_sock = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiClient::connected() {
|
||||||
|
|
||||||
|
if (_sock == 255) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
uint8_t s = status();
|
||||||
|
|
||||||
|
return !(s == LISTEN || s == CLOSED || s == FIN_WAIT_1 ||
|
||||||
|
s == FIN_WAIT_2 || s == TIME_WAIT ||
|
||||||
|
s == SYN_SENT || s== SYN_RCVD ||
|
||||||
|
(s == CLOSE_WAIT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiClient::status() {
|
||||||
|
if (_sock == 255) {
|
||||||
|
return CLOSED;
|
||||||
|
} else {
|
||||||
|
return ServerDrv::getClientState(_sock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFiClient::operator bool() {
|
||||||
|
return _sock != 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Private Methods
|
||||||
|
uint8_t WiFiClient::getFirstSocket()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < MAX_SOCK_NUM; i++) {
|
||||||
|
if (WiFiClass::_state[i] == NA_STATE)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SOCK_NOT_AVAIL;
|
||||||
|
}
|
||||||
|
|
59
WiFi/WiFiClient.h
Normal file
59
WiFi/WiFiClient.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
WiFiClient.cpp - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino LLC. 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 wificlient_h
|
||||||
|
#define wificlient_h
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "Print.h"
|
||||||
|
#include "Client.h"
|
||||||
|
#include "IPAddress.h"
|
||||||
|
|
||||||
|
class WiFiClient : public Client {
|
||||||
|
|
||||||
|
public:
|
||||||
|
WiFiClient();
|
||||||
|
WiFiClient(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 WiFiServer;
|
||||||
|
|
||||||
|
using Print::write;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static uint16_t _srcport;
|
||||||
|
uint8_t _sock; //not used
|
||||||
|
uint16_t _socket;
|
||||||
|
|
||||||
|
uint8_t getFirstSocket();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
108
WiFi/WiFiServer.cpp
Normal file
108
WiFi/WiFiServer.cpp
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
WiFiServer.cpp - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino LLC. 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "utility/server_drv.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "utility/debug.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "WiFi.h"
|
||||||
|
#include "WiFiClient.h"
|
||||||
|
#include "WiFiServer.h"
|
||||||
|
|
||||||
|
WiFiServer::WiFiServer(uint16_t port)
|
||||||
|
{
|
||||||
|
_port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiServer::begin()
|
||||||
|
{
|
||||||
|
uint8_t _sock = WiFiClass::getSocket();
|
||||||
|
if (_sock != NO_SOCKET_AVAIL)
|
||||||
|
{
|
||||||
|
ServerDrv::startServer(_port, _sock);
|
||||||
|
WiFiClass::_server_port[_sock] = _port;
|
||||||
|
WiFiClass::_state[_sock] = _sock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFiClient WiFiServer::available(byte* status)
|
||||||
|
{
|
||||||
|
static int cycle_server_down = 0;
|
||||||
|
const int TH_SERVER_DOWN = 50;
|
||||||
|
|
||||||
|
for (int sock = 0; sock < MAX_SOCK_NUM; sock++)
|
||||||
|
{
|
||||||
|
if (WiFiClass::_server_port[sock] == _port)
|
||||||
|
{
|
||||||
|
WiFiClient client(sock);
|
||||||
|
uint8_t _status = client.status();
|
||||||
|
uint8_t _ser_status = this->status();
|
||||||
|
|
||||||
|
if (status != NULL)
|
||||||
|
*status = _status;
|
||||||
|
|
||||||
|
//server not in listen state, restart it
|
||||||
|
if ((_ser_status == 0)&&(cycle_server_down++ > TH_SERVER_DOWN))
|
||||||
|
{
|
||||||
|
ServerDrv::startServer(_port, sock);
|
||||||
|
cycle_server_down = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_status == ESTABLISHED)
|
||||||
|
{
|
||||||
|
return client; //TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return WiFiClient(255);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiServer::status() {
|
||||||
|
return ServerDrv::getServerState(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t WiFiServer::write(uint8_t b)
|
||||||
|
{
|
||||||
|
return write(&b, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t WiFiServer::write(const uint8_t *buffer, size_t size)
|
||||||
|
{
|
||||||
|
size_t n = 0;
|
||||||
|
|
||||||
|
for (int sock = 0; sock < MAX_SOCK_NUM; sock++)
|
||||||
|
{
|
||||||
|
if (WiFiClass::_server_port[sock] != 0)
|
||||||
|
{
|
||||||
|
WiFiClient client(sock);
|
||||||
|
|
||||||
|
if (WiFiClass::_server_port[sock] == _port &&
|
||||||
|
client.status() == ESTABLISHED)
|
||||||
|
{
|
||||||
|
n+=client.write(buffer, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
46
WiFi/WiFiServer.h
Normal file
46
WiFi/WiFiServer.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
WiFiServer.h - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino LLC. 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 wifiserver_h
|
||||||
|
#define wifiserver_h
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "utility/wl_definitions.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "Server.h"
|
||||||
|
|
||||||
|
class WiFiClient;
|
||||||
|
|
||||||
|
class WiFiServer : public Server {
|
||||||
|
private:
|
||||||
|
uint16_t _port;
|
||||||
|
void* pcb;
|
||||||
|
public:
|
||||||
|
WiFiServer(uint16_t);
|
||||||
|
WiFiClient available(uint8_t* status = NULL);
|
||||||
|
void begin();
|
||||||
|
virtual size_t write(uint8_t);
|
||||||
|
virtual size_t write(const uint8_t *buf, size_t size);
|
||||||
|
uint8_t status();
|
||||||
|
|
||||||
|
using Print::write;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
181
WiFi/WiFiUdp.cpp
Normal file
181
WiFi/WiFiUdp.cpp
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
/*
|
||||||
|
WiFiUdp.cpp - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino LLC. 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "utility/debug.h"
|
||||||
|
#include "utility/wifi_spi.h"
|
||||||
|
}
|
||||||
|
#include <string.h>
|
||||||
|
#include "utility/server_drv.h"
|
||||||
|
#include "utility/wifi_drv.h"
|
||||||
|
|
||||||
|
#include "WiFi.h"
|
||||||
|
#include "WiFiUdp.h"
|
||||||
|
#include "WiFiClient.h"
|
||||||
|
#include "WiFiServer.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Constructor */
|
||||||
|
WiFiUDP::WiFiUDP() : _sock(NO_SOCKET_AVAIL) {}
|
||||||
|
|
||||||
|
/* Start WiFiUDP socket, listening at local port PORT */
|
||||||
|
uint8_t WiFiUDP::begin(uint16_t port) {
|
||||||
|
|
||||||
|
uint8_t sock = WiFiClass::getSocket();
|
||||||
|
if (sock != NO_SOCKET_AVAIL)
|
||||||
|
{
|
||||||
|
ServerDrv::startServer(port, sock, UDP_MODE);
|
||||||
|
WiFiClass::_server_port[sock] = port;
|
||||||
|
_sock = sock;
|
||||||
|
_port = port;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return number of bytes available in the current packet,
|
||||||
|
will return zero if parsePacket hasn't been called yet */
|
||||||
|
int WiFiUDP::available() {
|
||||||
|
if (_sock != NO_SOCKET_AVAIL)
|
||||||
|
{
|
||||||
|
return ServerDrv::availData(_sock);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release any resources being used by this WiFiUDP instance */
|
||||||
|
void WiFiUDP::stop()
|
||||||
|
{
|
||||||
|
if (_sock == NO_SOCKET_AVAIL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ServerDrv::stopClient(_sock);
|
||||||
|
|
||||||
|
_sock = NO_SOCKET_AVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiUDP::beginPacket(const char *host, uint16_t port)
|
||||||
|
{
|
||||||
|
// Look up the host first
|
||||||
|
int ret = 0;
|
||||||
|
IPAddress remote_addr;
|
||||||
|
if (WiFi.hostByName(host, remote_addr))
|
||||||
|
{
|
||||||
|
return beginPacket(remote_addr, port);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiUDP::beginPacket(IPAddress ip, uint16_t port)
|
||||||
|
{
|
||||||
|
if (_sock == NO_SOCKET_AVAIL)
|
||||||
|
_sock = WiFiClass::getSocket();
|
||||||
|
if (_sock != NO_SOCKET_AVAIL)
|
||||||
|
{
|
||||||
|
ServerDrv::startClient(uint32_t(ip), port, _sock, UDP_MODE);
|
||||||
|
WiFiClass::_state[_sock] = _sock;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiUDP::endPacket()
|
||||||
|
{
|
||||||
|
return ServerDrv::sendUdpData(_sock);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t WiFiUDP::write(uint8_t byte)
|
||||||
|
{
|
||||||
|
return write(&byte, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t WiFiUDP::write(const uint8_t *buffer, size_t size)
|
||||||
|
{
|
||||||
|
ServerDrv::insertDataBuf(_sock, buffer, size);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiUDP::parsePacket()
|
||||||
|
{
|
||||||
|
return available();
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiUDP::read()
|
||||||
|
{
|
||||||
|
uint8_t b;
|
||||||
|
if (available())
|
||||||
|
{
|
||||||
|
ServerDrv::getData(_sock, &b);
|
||||||
|
return b;
|
||||||
|
}else{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiUDP::read(unsigned char* buffer, size_t len)
|
||||||
|
{
|
||||||
|
if (available())
|
||||||
|
{
|
||||||
|
uint16_t size = 0;
|
||||||
|
if (!ServerDrv::getDataBuf(_sock, buffer, &size))
|
||||||
|
return -1;
|
||||||
|
// TODO check if the buffer is too smal respect to buffer size
|
||||||
|
return size;
|
||||||
|
}else{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiUDP::peek()
|
||||||
|
{
|
||||||
|
uint8_t b;
|
||||||
|
if (!available())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
ServerDrv::getData(_sock, &b, 1);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiUDP::flush()
|
||||||
|
{
|
||||||
|
while (available())
|
||||||
|
read();
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress WiFiUDP::remoteIP()
|
||||||
|
{
|
||||||
|
uint8_t _remoteIp[4] = {0};
|
||||||
|
uint8_t _remotePort[2] = {0};
|
||||||
|
|
||||||
|
WiFiDrv::getRemoteData(_sock, _remoteIp, _remotePort);
|
||||||
|
IPAddress ip(_remoteIp);
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t WiFiUDP::remotePort()
|
||||||
|
{
|
||||||
|
uint8_t _remoteIp[4] = {0};
|
||||||
|
uint8_t _remotePort[2] = {0};
|
||||||
|
|
||||||
|
WiFiDrv::getRemoteData(_sock, _remoteIp, _remotePort);
|
||||||
|
uint16_t port = (_remotePort[0]<<8)+_remotePort[1];
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
80
WiFi/WiFiUdp.h
Normal file
80
WiFi/WiFiUdp.h
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
WiFiUdp.h - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino LLC. 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 wifiudp_h
|
||||||
|
#define wifiudp_h
|
||||||
|
|
||||||
|
#include <Udp.h>
|
||||||
|
|
||||||
|
#define UDP_TX_PACKET_MAX_SIZE 24
|
||||||
|
|
||||||
|
class WiFiUDP : public UDP {
|
||||||
|
private:
|
||||||
|
uint8_t _sock; // socket ID for Wiz5100
|
||||||
|
uint16_t _port; // local port to listen on
|
||||||
|
|
||||||
|
public:
|
||||||
|
WiFiUDP(); // 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 the port of the host who sent the current incoming packet
|
||||||
|
virtual uint16_t remotePort();
|
||||||
|
|
||||||
|
friend class WiFiDrv;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
95
WiFi/utility/debug.h
Normal file
95
WiFi/utility/debug.h
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
debug.h - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino. 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
|
||||||
|
*/
|
||||||
|
//*********************************************/
|
||||||
|
//
|
||||||
|
// File: debug.h
|
||||||
|
//
|
||||||
|
// Author: dlf (Metodo2 srl)
|
||||||
|
//
|
||||||
|
//********************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef Debug_H
|
||||||
|
#define Debug_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define PRINT_FILE_LINE() do { \
|
||||||
|
Serial.print("[");Serial.print(__FILE__); \
|
||||||
|
Serial.print("::");Serial.print(__LINE__);Serial.print("]");\
|
||||||
|
}while (0);
|
||||||
|
|
||||||
|
#ifdef _DEBUG_
|
||||||
|
|
||||||
|
#define INFO(format, args...) do { \
|
||||||
|
char buf[250]; \
|
||||||
|
sprintf(buf, format, args); \
|
||||||
|
Serial.println(buf); \
|
||||||
|
} while(0);
|
||||||
|
|
||||||
|
#define INFO1(x) do { PRINT_FILE_LINE() Serial.print("-I-");\
|
||||||
|
Serial.println(x); \
|
||||||
|
}while (0);
|
||||||
|
|
||||||
|
|
||||||
|
#define INFO2(x,y) do { PRINT_FILE_LINE() Serial.print("-I-");\
|
||||||
|
Serial.print(x,16);Serial.print(",");Serial.println(y,16); \
|
||||||
|
}while (0);
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define INFO1(x) do {} while(0);
|
||||||
|
#define INFO2(x,y) do {} while(0);
|
||||||
|
#define INFO(format, args...) do {} while(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define WARN(args) do { PRINT_FILE_LINE() \
|
||||||
|
Serial.print("-W-"); Serial.println(args); \
|
||||||
|
}while (0);
|
||||||
|
#else
|
||||||
|
#define WARN(args) do {} while (0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _DEBUG_SPI_
|
||||||
|
#define DBG_PIN2 5
|
||||||
|
#define DBG_PIN 4
|
||||||
|
|
||||||
|
#define START() digitalWrite(DBG_PIN2, HIGH);
|
||||||
|
#define END() digitalWrite(DBG_PIN2, LOW);
|
||||||
|
#define SET_TRIGGER() digitalWrite(DBG_PIN, HIGH);
|
||||||
|
#define RST_TRIGGER() digitalWrite(DBG_PIN, LOW);
|
||||||
|
|
||||||
|
#define INIT_TRIGGER() pinMode(DBG_PIN, OUTPUT); \
|
||||||
|
pinMode(DBG_PIN2, OUTPUT); \
|
||||||
|
RST_TRIGGER()
|
||||||
|
#define TOGGLE_TRIGGER() SET_TRIGGER() \
|
||||||
|
delayMicroseconds(2); \
|
||||||
|
RST_TRIGGER()
|
||||||
|
#else
|
||||||
|
#define START()
|
||||||
|
#define END()
|
||||||
|
#define SET_TRIGGER()
|
||||||
|
#define RST_TRIGGER()
|
||||||
|
#define INIT_TRIGGER()
|
||||||
|
#define TOGGLE_TRIGGER()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
327
WiFi/utility/server_drv.cpp
Normal file
327
WiFi/utility/server_drv.cpp
Normal file
@ -0,0 +1,327 @@
|
|||||||
|
/*
|
||||||
|
server_drv.cpp - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino. 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#define _DEBUG_
|
||||||
|
|
||||||
|
#include "utility/server_drv.h"
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "utility/spi_drv.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "utility/wl_types.h"
|
||||||
|
#include "utility/debug.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Start server TCP on port specified
|
||||||
|
void ServerDrv::startServer(uint16_t port, uint8_t sock, uint8_t protMode)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(START_SERVER_TCP_CMD, PARAM_NUMS_3);
|
||||||
|
SpiDrv::sendParam(port);
|
||||||
|
SpiDrv::sendParam(&sock, 1);
|
||||||
|
SpiDrv::sendParam(&protMode, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(START_SERVER_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start server TCP on port specified
|
||||||
|
void ServerDrv::startClient(uint32_t ipAddress, uint16_t port, uint8_t sock, uint8_t protMode)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(START_CLIENT_TCP_CMD, PARAM_NUMS_4);
|
||||||
|
SpiDrv::sendParam((uint8_t*)&ipAddress, sizeof(ipAddress));
|
||||||
|
SpiDrv::sendParam(port);
|
||||||
|
SpiDrv::sendParam(&sock, 1);
|
||||||
|
SpiDrv::sendParam(&protMode, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(START_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start server TCP on port specified
|
||||||
|
void ServerDrv::stopClient(uint8_t sock)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(STOP_CLIENT_TCP_CMD, PARAM_NUMS_1);
|
||||||
|
SpiDrv::sendParam(&sock, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(STOP_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t ServerDrv::getServerState(uint8_t sock)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_STATE_TCP_CMD, PARAM_NUMS_1);
|
||||||
|
SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(GET_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
return _data;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ServerDrv::getClientState(uint8_t sock)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_CLIENT_STATE_TCP_CMD, PARAM_NUMS_1);
|
||||||
|
SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(GET_CLIENT_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
return _data;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t ServerDrv::availData(uint8_t sock)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(AVAIL_DATA_TCP_CMD, PARAM_NUMS_1);
|
||||||
|
SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
uint16_t len = 0;
|
||||||
|
|
||||||
|
SpiDrv::waitResponseCmd(AVAIL_DATA_TCP_CMD, PARAM_NUMS_1, (uint8_t*)&len, &_dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServerDrv::getData(uint8_t sock, uint8_t *data, uint8_t peek)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_DATA_TCP_CMD, PARAM_NUMS_2);
|
||||||
|
SpiDrv::sendParam(&sock, sizeof(sock));
|
||||||
|
SpiDrv::sendParam(peek, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseData8(GET_DATA_TCP_CMD, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
if (_dataLen!=0)
|
||||||
|
{
|
||||||
|
*data = _data;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServerDrv::getDataBuf(uint8_t sock, uint8_t *_data, uint16_t *_dataLen)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_DATABUF_TCP_CMD, PARAM_NUMS_1);
|
||||||
|
SpiDrv::sendBuffer(&sock, sizeof(sock), LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
if (!SpiDrv::waitResponseData16(GET_DATABUF_TCP_CMD, _data, _dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
if (*_dataLen!=0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServerDrv::insertDataBuf(uint8_t sock, const uint8_t *data, uint16_t _len)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(INSERT_DATABUF_CMD, PARAM_NUMS_2);
|
||||||
|
SpiDrv::sendBuffer(&sock, sizeof(sock));
|
||||||
|
SpiDrv::sendBuffer((uint8_t *)data, _len, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseData8(INSERT_DATABUF_CMD, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
if (_dataLen!=0)
|
||||||
|
{
|
||||||
|
return (_data == 1);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ServerDrv::sendUdpData(uint8_t sock)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(SEND_DATA_UDP_CMD, PARAM_NUMS_1);
|
||||||
|
SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseData8(SEND_DATA_UDP_CMD, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
if (_dataLen!=0)
|
||||||
|
{
|
||||||
|
return (_data == 1);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ServerDrv::sendData(uint8_t sock, const uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(SEND_DATA_TCP_CMD, PARAM_NUMS_2);
|
||||||
|
SpiDrv::sendBuffer(&sock, sizeof(sock));
|
||||||
|
SpiDrv::sendBuffer((uint8_t *)data, len, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseData8(SEND_DATA_TCP_CMD, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
if (_dataLen!=0)
|
||||||
|
{
|
||||||
|
return (_data == 1);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t ServerDrv::checkDataSent(uint8_t sock)
|
||||||
|
{
|
||||||
|
const uint16_t TIMEOUT_DATA_SENT = 25;
|
||||||
|
uint16_t timeout = 0;
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1);
|
||||||
|
SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
if (!SpiDrv::waitResponseCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse isDataSent");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
if (_data) timeout = 0;
|
||||||
|
else{
|
||||||
|
++timeout;
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
}while((_data==0)&&(timeout<TIMEOUT_DATA_SENT));
|
||||||
|
return (timeout==TIMEOUT_DATA_SENT)?0:1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerDrv serverDrv;
|
60
WiFi/utility/server_drv.h
Normal file
60
WiFi/utility/server_drv.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
server_drv.h - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino. 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 Server_Drv_h
|
||||||
|
#define Server_Drv_h
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "utility/wifi_spi.h"
|
||||||
|
|
||||||
|
typedef enum eProtMode {TCP_MODE, UDP_MODE}tProtMode;
|
||||||
|
|
||||||
|
class ServerDrv
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Start server TCP on port specified
|
||||||
|
static void startServer(uint16_t port, uint8_t sock, uint8_t protMode=TCP_MODE);
|
||||||
|
|
||||||
|
static void startClient(uint32_t ipAddress, uint16_t port, uint8_t sock, uint8_t protMode=TCP_MODE);
|
||||||
|
|
||||||
|
static void stopClient(uint8_t sock);
|
||||||
|
|
||||||
|
static uint8_t getServerState(uint8_t sock);
|
||||||
|
|
||||||
|
static uint8_t getClientState(uint8_t sock);
|
||||||
|
|
||||||
|
static bool getData(uint8_t sock, uint8_t *data, uint8_t peek = 0);
|
||||||
|
|
||||||
|
static bool getDataBuf(uint8_t sock, uint8_t *data, uint16_t *len);
|
||||||
|
|
||||||
|
static bool insertDataBuf(uint8_t sock, const uint8_t *_data, uint16_t _dataLen);
|
||||||
|
|
||||||
|
static bool sendData(uint8_t sock, const uint8_t *data, uint16_t len);
|
||||||
|
|
||||||
|
static bool sendUdpData(uint8_t sock);
|
||||||
|
|
||||||
|
static uint16_t availData(uint8_t sock);
|
||||||
|
|
||||||
|
static uint8_t checkDataSent(uint8_t sock);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern ServerDrv serverDrv;
|
||||||
|
|
||||||
|
#endif
|
496
WiFi/utility/spi_drv.cpp
Normal file
496
WiFi/utility/spi_drv.cpp
Normal file
@ -0,0 +1,496 @@
|
|||||||
|
/*
|
||||||
|
spi_drv.cpp - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino. 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include <SPI.h>
|
||||||
|
#include "utility/spi_drv.h"
|
||||||
|
#include "pins_arduino.h"
|
||||||
|
//#define _DEBUG_
|
||||||
|
extern "C" {
|
||||||
|
#include "utility/debug.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DATAOUT 11 // MOSI
|
||||||
|
#define DATAIN 12 // MISO
|
||||||
|
#define SPICLOCK 13 // sck
|
||||||
|
#define SLAVESELECT 10 // ss
|
||||||
|
#define SLAVEREADY 7 // handshake pin
|
||||||
|
#define WIFILED 9 // led on wifi shield
|
||||||
|
|
||||||
|
#define DELAY_SPI(X) { int ii=0; do { asm volatile("nop"); } while (++ii < (X*F_CPU/16000000)); }
|
||||||
|
#define DELAY_TRANSFER() DELAY_SPI(10)
|
||||||
|
|
||||||
|
void SpiDrv::begin()
|
||||||
|
{
|
||||||
|
SPI.begin();
|
||||||
|
pinMode(SLAVESELECT, OUTPUT);
|
||||||
|
pinMode(SLAVEREADY, INPUT);
|
||||||
|
pinMode(WIFILED, OUTPUT);
|
||||||
|
|
||||||
|
// digitalWrite(SCK, LOW);
|
||||||
|
// digitalWrite(MOSI, LOW);
|
||||||
|
digitalWrite(SS, HIGH);
|
||||||
|
digitalWrite(SLAVESELECT, HIGH);
|
||||||
|
digitalWrite(WIFILED, LOW);
|
||||||
|
|
||||||
|
#ifdef _DEBUG_
|
||||||
|
INIT_TRIGGER()
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpiDrv::end() {
|
||||||
|
SPI.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpiDrv::spiSlaveSelect()
|
||||||
|
{
|
||||||
|
digitalWrite(SLAVESELECT,LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SpiDrv::spiSlaveDeselect()
|
||||||
|
{
|
||||||
|
digitalWrite(SLAVESELECT,HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char SpiDrv::spiTransfer(volatile char data)
|
||||||
|
{
|
||||||
|
char result = SPI.transfer(data);
|
||||||
|
DELAY_TRANSFER();
|
||||||
|
|
||||||
|
return result; // return the received byte
|
||||||
|
}
|
||||||
|
|
||||||
|
int SpiDrv::waitSpiChar(unsigned char waitChar)
|
||||||
|
{
|
||||||
|
int timeout = TIMEOUT_CHAR;
|
||||||
|
unsigned char _readChar = 0;
|
||||||
|
do{
|
||||||
|
_readChar = readChar(); //get data byte
|
||||||
|
if (_readChar == ERR_CMD)
|
||||||
|
{
|
||||||
|
WARN("Err cmd received\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}while((timeout-- > 0) && (_readChar != waitChar));
|
||||||
|
return (_readChar == waitChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
int SpiDrv::readAndCheckChar(char checkChar, char* readChar)
|
||||||
|
{
|
||||||
|
getParam((uint8_t*)readChar);
|
||||||
|
|
||||||
|
return (*readChar == checkChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
char SpiDrv::readChar()
|
||||||
|
{
|
||||||
|
uint8_t readChar = 0;
|
||||||
|
getParam(&readChar);
|
||||||
|
return readChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define WAIT_START_CMD(x) waitSpiChar(START_CMD)
|
||||||
|
|
||||||
|
#define IF_CHECK_START_CMD(x) \
|
||||||
|
if (!WAIT_START_CMD(_data)) \
|
||||||
|
{ \
|
||||||
|
TOGGLE_TRIGGER() \
|
||||||
|
WARN("Error waiting START_CMD"); \
|
||||||
|
return 0; \
|
||||||
|
}else \
|
||||||
|
|
||||||
|
#define CHECK_DATA(check, x) \
|
||||||
|
if (!readAndCheckChar(check, &x)) \
|
||||||
|
{ \
|
||||||
|
TOGGLE_TRIGGER() \
|
||||||
|
WARN("Reply error"); \
|
||||||
|
INFO2(check, (uint8_t)x); \
|
||||||
|
return 0; \
|
||||||
|
}else \
|
||||||
|
|
||||||
|
#define waitSlaveReady() (digitalRead(SLAVEREADY) == LOW)
|
||||||
|
#define waitSlaveSign() (digitalRead(SLAVEREADY) == HIGH)
|
||||||
|
#define waitSlaveSignalH() while(digitalRead(SLAVEREADY) != HIGH){}
|
||||||
|
#define waitSlaveSignalL() while(digitalRead(SLAVEREADY) != LOW){}
|
||||||
|
|
||||||
|
void SpiDrv::waitForSlaveSign()
|
||||||
|
{
|
||||||
|
while (!waitSlaveSign());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpiDrv::waitForSlaveReady()
|
||||||
|
{
|
||||||
|
while (!waitSlaveReady());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpiDrv::getParam(uint8_t* param)
|
||||||
|
{
|
||||||
|
// Get Params data
|
||||||
|
*param = spiTransfer(DUMMY_DATA);
|
||||||
|
DELAY_TRANSFER();
|
||||||
|
}
|
||||||
|
|
||||||
|
int SpiDrv::waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len)
|
||||||
|
{
|
||||||
|
char _data = 0;
|
||||||
|
int ii = 0;
|
||||||
|
|
||||||
|
IF_CHECK_START_CMD(_data)
|
||||||
|
{
|
||||||
|
CHECK_DATA(cmd | REPLY_FLAG, _data){};
|
||||||
|
|
||||||
|
CHECK_DATA(numParam, _data);
|
||||||
|
{
|
||||||
|
readParamLen8(param_len);
|
||||||
|
for (ii=0; ii<(*param_len); ++ii)
|
||||||
|
{
|
||||||
|
// Get Params data
|
||||||
|
//param[ii] = spiTransfer(DUMMY_DATA);
|
||||||
|
getParam(¶m[ii]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readAndCheckChar(END_CMD, &_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
int SpiDrv::waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint16_t* param_len)
|
||||||
|
{
|
||||||
|
char _data = 0;
|
||||||
|
int i =0, ii = 0;
|
||||||
|
|
||||||
|
IF_CHECK_START_CMD(_data)
|
||||||
|
{
|
||||||
|
CHECK_DATA(cmd | REPLY_FLAG, _data){};
|
||||||
|
|
||||||
|
CHECK_DATA(numParam, _data);
|
||||||
|
{
|
||||||
|
readParamLen16(param_len);
|
||||||
|
for (ii=0; ii<(*param_len); ++ii)
|
||||||
|
{
|
||||||
|
// Get Params data
|
||||||
|
param[ii] = spiTransfer(DUMMY_DATA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readAndCheckChar(END_CMD, &_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
int SpiDrv::waitResponseData16(uint8_t cmd, uint8_t* param, uint16_t* param_len)
|
||||||
|
{
|
||||||
|
char _data = 0;
|
||||||
|
uint16_t ii = 0;
|
||||||
|
|
||||||
|
IF_CHECK_START_CMD(_data)
|
||||||
|
{
|
||||||
|
CHECK_DATA(cmd | REPLY_FLAG, _data){};
|
||||||
|
|
||||||
|
uint8_t numParam = readChar();
|
||||||
|
if (numParam != 0)
|
||||||
|
{
|
||||||
|
readParamLen16(param_len);
|
||||||
|
for (ii=0; ii<(*param_len); ++ii)
|
||||||
|
{
|
||||||
|
// Get Params data
|
||||||
|
param[ii] = spiTransfer(DUMMY_DATA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readAndCheckChar(END_CMD, &_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SpiDrv::waitResponseData8(uint8_t cmd, uint8_t* param, uint8_t* param_len)
|
||||||
|
{
|
||||||
|
char _data = 0;
|
||||||
|
int ii = 0;
|
||||||
|
|
||||||
|
IF_CHECK_START_CMD(_data)
|
||||||
|
{
|
||||||
|
CHECK_DATA(cmd | REPLY_FLAG, _data){};
|
||||||
|
|
||||||
|
uint8_t numParam = readChar();
|
||||||
|
if (numParam != 0)
|
||||||
|
{
|
||||||
|
readParamLen8(param_len);
|
||||||
|
for (ii=0; ii<(*param_len); ++ii)
|
||||||
|
{
|
||||||
|
// Get Params data
|
||||||
|
param[ii] = spiTransfer(DUMMY_DATA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readAndCheckChar(END_CMD, &_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SpiDrv::waitResponseParams(uint8_t cmd, uint8_t numParam, tParam* params)
|
||||||
|
{
|
||||||
|
char _data = 0;
|
||||||
|
int i =0, ii = 0;
|
||||||
|
|
||||||
|
|
||||||
|
IF_CHECK_START_CMD(_data)
|
||||||
|
{
|
||||||
|
CHECK_DATA(cmd | REPLY_FLAG, _data){};
|
||||||
|
|
||||||
|
uint8_t _numParam = readChar();
|
||||||
|
if (_numParam != 0)
|
||||||
|
{
|
||||||
|
for (i=0; i<_numParam; ++i)
|
||||||
|
{
|
||||||
|
params[i].paramLen = readParamLen8();
|
||||||
|
for (ii=0; ii<params[i].paramLen; ++ii)
|
||||||
|
{
|
||||||
|
// Get Params data
|
||||||
|
params[i].param[ii] = spiTransfer(DUMMY_DATA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
WARN("Error numParam == 0");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numParam != _numParam)
|
||||||
|
{
|
||||||
|
WARN("Mismatch numParam");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
readAndCheckChar(END_CMD, &_data);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
int SpiDrv::waitResponse(uint8_t cmd, tParam* params, uint8_t* numParamRead, uint8_t maxNumParams)
|
||||||
|
{
|
||||||
|
char _data = 0;
|
||||||
|
int i =0, ii = 0;
|
||||||
|
|
||||||
|
IF_CHECK_START_CMD(_data)
|
||||||
|
{
|
||||||
|
CHECK_DATA(cmd | REPLY_FLAG, _data){};
|
||||||
|
|
||||||
|
uint8_t numParam = readChar();
|
||||||
|
|
||||||
|
if (numParam > maxNumParams)
|
||||||
|
{
|
||||||
|
numParam = maxNumParams;
|
||||||
|
}
|
||||||
|
*numParamRead = numParam;
|
||||||
|
if (numParam != 0)
|
||||||
|
{
|
||||||
|
for (i=0; i<numParam; ++i)
|
||||||
|
{
|
||||||
|
params[i].paramLen = readParamLen8();
|
||||||
|
|
||||||
|
for (ii=0; ii<params[i].paramLen; ++ii)
|
||||||
|
{
|
||||||
|
// Get Params data
|
||||||
|
params[i].param[ii] = spiTransfer(DUMMY_DATA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
WARN("Error numParams == 0");
|
||||||
|
Serial.println(cmd, 16);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
readAndCheckChar(END_CMD, &_data);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
int SpiDrv::waitResponse(uint8_t cmd, uint8_t* numParamRead, uint8_t** params, uint8_t maxNumParams)
|
||||||
|
{
|
||||||
|
char _data = 0;
|
||||||
|
int i =0, ii = 0;
|
||||||
|
|
||||||
|
char *index[WL_SSID_MAX_LENGTH];
|
||||||
|
|
||||||
|
for (i = 0 ; i < WL_NETWORKS_LIST_MAXNUM ; i++)
|
||||||
|
index[i] = (char *)params + WL_SSID_MAX_LENGTH*i;
|
||||||
|
|
||||||
|
IF_CHECK_START_CMD(_data)
|
||||||
|
{
|
||||||
|
CHECK_DATA(cmd | REPLY_FLAG, _data){};
|
||||||
|
|
||||||
|
uint8_t numParam = readChar();
|
||||||
|
|
||||||
|
if (numParam > maxNumParams)
|
||||||
|
{
|
||||||
|
numParam = maxNumParams;
|
||||||
|
}
|
||||||
|
*numParamRead = numParam;
|
||||||
|
if (numParam != 0)
|
||||||
|
{
|
||||||
|
for (i=0; i<numParam; ++i)
|
||||||
|
{
|
||||||
|
uint8_t paramLen = readParamLen8();
|
||||||
|
for (ii=0; ii<paramLen; ++ii)
|
||||||
|
{
|
||||||
|
//ssid[ii] = spiTransfer(DUMMY_DATA);
|
||||||
|
// Get Params data
|
||||||
|
index[i][ii] = (uint8_t)spiTransfer(DUMMY_DATA);
|
||||||
|
|
||||||
|
}
|
||||||
|
index[i][ii]=0;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
WARN("Error numParams == 0");
|
||||||
|
readAndCheckChar(END_CMD, &_data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
readAndCheckChar(END_CMD, &_data);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SpiDrv::sendParam(uint8_t* param, uint8_t param_len, uint8_t lastParam)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
// Send Spi paramLen
|
||||||
|
sendParamLen8(param_len);
|
||||||
|
|
||||||
|
// Send Spi param data
|
||||||
|
for (i=0; i<param_len; ++i)
|
||||||
|
{
|
||||||
|
spiTransfer(param[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if lastParam==1 Send Spi END CMD
|
||||||
|
if (lastParam == 1)
|
||||||
|
spiTransfer(END_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpiDrv::sendParamLen8(uint8_t param_len)
|
||||||
|
{
|
||||||
|
// Send Spi paramLen
|
||||||
|
spiTransfer(param_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpiDrv::sendParamLen16(uint16_t param_len)
|
||||||
|
{
|
||||||
|
// Send Spi paramLen
|
||||||
|
spiTransfer((uint8_t)((param_len & 0xff00)>>8));
|
||||||
|
spiTransfer((uint8_t)(param_len & 0xff));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t SpiDrv::readParamLen8(uint8_t* param_len)
|
||||||
|
{
|
||||||
|
uint8_t _param_len = spiTransfer(DUMMY_DATA);
|
||||||
|
if (param_len != NULL)
|
||||||
|
{
|
||||||
|
*param_len = _param_len;
|
||||||
|
}
|
||||||
|
return _param_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t SpiDrv::readParamLen16(uint16_t* param_len)
|
||||||
|
{
|
||||||
|
uint16_t _param_len = spiTransfer(DUMMY_DATA)<<8 | (spiTransfer(DUMMY_DATA)& 0xff);
|
||||||
|
if (param_len != NULL)
|
||||||
|
{
|
||||||
|
*param_len = _param_len;
|
||||||
|
}
|
||||||
|
return _param_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SpiDrv::sendBuffer(uint8_t* param, uint16_t param_len, uint8_t lastParam)
|
||||||
|
{
|
||||||
|
uint16_t i = 0;
|
||||||
|
|
||||||
|
// Send Spi paramLen
|
||||||
|
sendParamLen16(param_len);
|
||||||
|
|
||||||
|
// Send Spi param data
|
||||||
|
for (i=0; i<param_len; ++i)
|
||||||
|
{
|
||||||
|
spiTransfer(param[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if lastParam==1 Send Spi END CMD
|
||||||
|
if (lastParam == 1)
|
||||||
|
spiTransfer(END_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SpiDrv::sendParam(uint16_t param, uint8_t lastParam)
|
||||||
|
{
|
||||||
|
// Send Spi paramLen
|
||||||
|
sendParamLen8(2);
|
||||||
|
|
||||||
|
spiTransfer((uint8_t)((param & 0xff00)>>8));
|
||||||
|
spiTransfer((uint8_t)(param & 0xff));
|
||||||
|
|
||||||
|
// if lastParam==1 Send Spi END CMD
|
||||||
|
if (lastParam == 1)
|
||||||
|
spiTransfer(END_CMD);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cmd Struct Message */
|
||||||
|
/* _________________________________________________________________________________ */
|
||||||
|
/*| START CMD | C/R | CMD |[TOT LEN]| N.PARAM | PARAM LEN | PARAM | .. | END CMD | */
|
||||||
|
/*|___________|______|______|_________|_________|___________|________|____|_________| */
|
||||||
|
/*| 8 bit | 1bit | 7bit | 8bit | 8bit | 8bit | nbytes | .. | 8bit | */
|
||||||
|
/*|___________|______|______|_________|_________|___________|________|____|_________| */
|
||||||
|
|
||||||
|
void SpiDrv::sendCmd(uint8_t cmd, uint8_t numParam)
|
||||||
|
{
|
||||||
|
// Send Spi START CMD
|
||||||
|
spiTransfer(START_CMD);
|
||||||
|
|
||||||
|
//waitForSlaveSign();
|
||||||
|
//wait the interrupt trigger on slave
|
||||||
|
delayMicroseconds(SPI_START_CMD_DELAY);
|
||||||
|
|
||||||
|
// Send Spi C + cmd
|
||||||
|
spiTransfer(cmd & ~(REPLY_FLAG));
|
||||||
|
|
||||||
|
// Send Spi totLen
|
||||||
|
//spiTransfer(totLen);
|
||||||
|
|
||||||
|
// Send Spi numParam
|
||||||
|
spiTransfer(numParam);
|
||||||
|
|
||||||
|
// If numParam == 0 send END CMD
|
||||||
|
if (numParam == 0)
|
||||||
|
spiTransfer(END_CMD);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SpiDrv spiDrv;
|
106
WiFi/utility/spi_drv.h
Normal file
106
WiFi/utility/spi_drv.h
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
spi_drv.h - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino. 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 SPI_Drv_h
|
||||||
|
#define SPI_Drv_h
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "utility/wifi_spi.h"
|
||||||
|
|
||||||
|
#define SPI_START_CMD_DELAY 10
|
||||||
|
|
||||||
|
#define NO_LAST_PARAM 0
|
||||||
|
#define LAST_PARAM 1
|
||||||
|
|
||||||
|
#define DUMMY_DATA 0xFF
|
||||||
|
|
||||||
|
#define WAIT_FOR_SLAVE_SELECT() \
|
||||||
|
if (!initialized) { \
|
||||||
|
SpiDrv::begin(); \
|
||||||
|
initialized = true; \
|
||||||
|
} \
|
||||||
|
SpiDrv::waitForSlaveReady(); \
|
||||||
|
SpiDrv::spiSlaveSelect();
|
||||||
|
|
||||||
|
static bool initialized = false;
|
||||||
|
|
||||||
|
class SpiDrv
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
//static bool waitSlaveReady();
|
||||||
|
static void waitForSlaveSign();
|
||||||
|
static void getParam(uint8_t* param);
|
||||||
|
public:
|
||||||
|
|
||||||
|
static void begin();
|
||||||
|
|
||||||
|
static void end();
|
||||||
|
|
||||||
|
static void spiDriverInit();
|
||||||
|
|
||||||
|
static void spiSlaveSelect();
|
||||||
|
|
||||||
|
static void spiSlaveDeselect();
|
||||||
|
|
||||||
|
static char spiTransfer(volatile char data);
|
||||||
|
|
||||||
|
static void waitForSlaveReady();
|
||||||
|
|
||||||
|
//static int waitSpiChar(char waitChar, char* readChar);
|
||||||
|
|
||||||
|
static int waitSpiChar(unsigned char waitChar);
|
||||||
|
|
||||||
|
static int readAndCheckChar(char checkChar, char* readChar);
|
||||||
|
|
||||||
|
static char readChar();
|
||||||
|
|
||||||
|
static int waitResponseParams(uint8_t cmd, uint8_t numParam, tParam* params);
|
||||||
|
|
||||||
|
static int waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len);
|
||||||
|
|
||||||
|
static int waitResponseData8(uint8_t cmd, uint8_t* param, uint8_t* param_len);
|
||||||
|
|
||||||
|
static int waitResponseData16(uint8_t cmd, uint8_t* param, uint16_t* param_len);
|
||||||
|
/*
|
||||||
|
static int waitResponse(uint8_t cmd, tParam* params, uint8_t* numParamRead, uint8_t maxNumParams);
|
||||||
|
|
||||||
|
static int waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint16_t* param_len);
|
||||||
|
*/
|
||||||
|
static int waitResponse(uint8_t cmd, uint8_t* numParamRead, uint8_t** params, uint8_t maxNumParams);
|
||||||
|
|
||||||
|
static void sendParam(uint8_t* param, uint8_t param_len, uint8_t lastParam = NO_LAST_PARAM);
|
||||||
|
|
||||||
|
static void sendParamLen8(uint8_t param_len);
|
||||||
|
|
||||||
|
static void sendParamLen16(uint16_t param_len);
|
||||||
|
|
||||||
|
static uint8_t readParamLen8(uint8_t* param_len = NULL);
|
||||||
|
|
||||||
|
static uint16_t readParamLen16(uint16_t* param_len = NULL);
|
||||||
|
|
||||||
|
static void sendBuffer(uint8_t* param, uint16_t param_len, uint8_t lastParam = NO_LAST_PARAM);
|
||||||
|
|
||||||
|
static void sendParam(uint16_t param, uint8_t lastParam = NO_LAST_PARAM);
|
||||||
|
|
||||||
|
static void sendCmd(uint8_t cmd, uint8_t numParam);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern SpiDrv spiDrv;
|
||||||
|
|
||||||
|
#endif
|
579
WiFi/utility/wifi_drv.cpp
Normal file
579
WiFi/utility/wifi_drv.cpp
Normal file
@ -0,0 +1,579 @@
|
|||||||
|
/*
|
||||||
|
wifi_drv.cpp - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino. 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "utility/spi_drv.h"
|
||||||
|
#include "utility/wifi_drv.h"
|
||||||
|
|
||||||
|
#define _DEBUG_
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "utility/wifi_spi.h"
|
||||||
|
#include "utility/wl_types.h"
|
||||||
|
#include "utility/debug.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Array of data to cache the information related to the networks discovered
|
||||||
|
char WiFiDrv::_networkSsid[][WL_SSID_MAX_LENGTH] = {{"1"},{"2"},{"3"},{"4"},{"5"}};
|
||||||
|
int32_t WiFiDrv::_networkRssi[WL_NETWORKS_LIST_MAXNUM] = { 0 };
|
||||||
|
uint8_t WiFiDrv::_networkEncr[WL_NETWORKS_LIST_MAXNUM] = { 0 };
|
||||||
|
|
||||||
|
// Cached values of retrieved data
|
||||||
|
char WiFiDrv::_ssid[] = {0};
|
||||||
|
uint8_t WiFiDrv::_bssid[] = {0};
|
||||||
|
uint8_t WiFiDrv::_mac[] = {0};
|
||||||
|
uint8_t WiFiDrv::_localIp[] = {0};
|
||||||
|
uint8_t WiFiDrv::_subnetMask[] = {0};
|
||||||
|
uint8_t WiFiDrv::_gatewayIp[] = {0};
|
||||||
|
// Firmware version
|
||||||
|
char WiFiDrv::fwVersion[] = {0};
|
||||||
|
|
||||||
|
|
||||||
|
// Private Methods
|
||||||
|
|
||||||
|
void WiFiDrv::getNetworkData(uint8_t *ip, uint8_t *mask, uint8_t *gwip)
|
||||||
|
{
|
||||||
|
tParam params[PARAM_NUMS_3] = { {0, (char*)ip}, {0, (char*)mask}, {0, (char*)gwip}};
|
||||||
|
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_IPADDR_CMD, PARAM_NUMS_1);
|
||||||
|
|
||||||
|
uint8_t _dummy = DUMMY_DATA;
|
||||||
|
SpiDrv::sendParam(&_dummy, sizeof(_dummy), LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
SpiDrv::waitResponseParams(GET_IPADDR_CMD, PARAM_NUMS_3, params);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiDrv::getRemoteData(uint8_t sock, uint8_t *ip, uint8_t *port)
|
||||||
|
{
|
||||||
|
tParam params[PARAM_NUMS_2] = { {0, (char*)ip}, {0, (char*)port} };
|
||||||
|
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_REMOTE_DATA_CMD, PARAM_NUMS_1);
|
||||||
|
SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
SpiDrv::waitResponseParams(GET_REMOTE_DATA_CMD, PARAM_NUMS_2, params);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Public Methods
|
||||||
|
|
||||||
|
|
||||||
|
void WiFiDrv::wifiDriverInit()
|
||||||
|
{
|
||||||
|
SpiDrv::begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t WiFiDrv::wifiSetNetwork(char* ssid, uint8_t ssid_len)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(SET_NET_CMD, PARAM_NUMS_1);
|
||||||
|
SpiDrv::sendParam((uint8_t*)ssid, ssid_len, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(SET_NET_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
_data = WL_FAILURE;
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return(_data == WIFI_SPI_ACK) ? WL_SUCCESS : WL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t WiFiDrv::wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(SET_PASSPHRASE_CMD, PARAM_NUMS_2);
|
||||||
|
SpiDrv::sendParam((uint8_t*)ssid, ssid_len, NO_LAST_PARAM);
|
||||||
|
SpiDrv::sendParam((uint8_t*)passphrase, len, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(SET_PASSPHRASE_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
_data = WL_FAILURE;
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
return _data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int8_t WiFiDrv::wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(SET_KEY_CMD, PARAM_NUMS_3);
|
||||||
|
SpiDrv::sendParam((uint8_t*)ssid, ssid_len, NO_LAST_PARAM);
|
||||||
|
SpiDrv::sendParam(&key_idx, KEY_IDX_LEN, NO_LAST_PARAM);
|
||||||
|
SpiDrv::sendParam((uint8_t*)key, len, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(SET_KEY_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
_data = WL_FAILURE;
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
return _data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiDrv::config(uint8_t validParams, uint32_t local_ip, uint32_t gateway, uint32_t subnet)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(SET_IP_CONFIG_CMD, PARAM_NUMS_4);
|
||||||
|
SpiDrv::sendParam((uint8_t*)&validParams, 1, NO_LAST_PARAM);
|
||||||
|
SpiDrv::sendParam((uint8_t*)&local_ip, 4, NO_LAST_PARAM);
|
||||||
|
SpiDrv::sendParam((uint8_t*)&gateway, 4, NO_LAST_PARAM);
|
||||||
|
SpiDrv::sendParam((uint8_t*)&subnet, 4, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(SET_IP_CONFIG_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
_data = WL_FAILURE;
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiDrv::setDNS(uint8_t validParams, uint32_t dns_server1, uint32_t dns_server2)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(SET_DNS_CONFIG_CMD, PARAM_NUMS_3);
|
||||||
|
SpiDrv::sendParam((uint8_t*)&validParams, 1, NO_LAST_PARAM);
|
||||||
|
SpiDrv::sendParam((uint8_t*)&dns_server1, 4, NO_LAST_PARAM);
|
||||||
|
SpiDrv::sendParam((uint8_t*)&dns_server2, 4, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(SET_DNS_CONFIG_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
_data = WL_FAILURE;
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int8_t WiFiDrv::disconnect()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(DISCONNECT_CMD, PARAM_NUMS_1);
|
||||||
|
|
||||||
|
uint8_t _dummy = DUMMY_DATA;
|
||||||
|
SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
int8_t result = SpiDrv::waitResponseCmd(DISCONNECT_CMD, PARAM_NUMS_1, &_data, &_dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiDrv::getConnectionStatus()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_CONN_STATUS_CMD, PARAM_NUMS_0);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = -1;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
SpiDrv::waitResponseCmd(GET_CONN_STATUS_CMD, PARAM_NUMS_1, &_data, &_dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return _data;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* WiFiDrv::getMacAddress()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_MACADDR_CMD, PARAM_NUMS_1);
|
||||||
|
|
||||||
|
uint8_t _dummy = DUMMY_DATA;
|
||||||
|
SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
SpiDrv::waitResponseCmd(GET_MACADDR_CMD, PARAM_NUMS_1, _mac, &_dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return _mac;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiDrv::getIpAddress(IPAddress& ip)
|
||||||
|
{
|
||||||
|
getNetworkData(_localIp, _subnetMask, _gatewayIp);
|
||||||
|
ip = _localIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiDrv::getSubnetMask(IPAddress& mask)
|
||||||
|
{
|
||||||
|
getNetworkData(_localIp, _subnetMask, _gatewayIp);
|
||||||
|
mask = _subnetMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiDrv::getGatewayIP(IPAddress& ip)
|
||||||
|
{
|
||||||
|
getNetworkData(_localIp, _subnetMask, _gatewayIp);
|
||||||
|
ip = _gatewayIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* WiFiDrv::getCurrentSSID()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_CURR_SSID_CMD, PARAM_NUMS_1);
|
||||||
|
|
||||||
|
uint8_t _dummy = DUMMY_DATA;
|
||||||
|
SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
SpiDrv::waitResponseCmd(GET_CURR_SSID_CMD, PARAM_NUMS_1, (uint8_t*)_ssid, &_dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return _ssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* WiFiDrv::getCurrentBSSID()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_CURR_BSSID_CMD, PARAM_NUMS_1);
|
||||||
|
|
||||||
|
uint8_t _dummy = DUMMY_DATA;
|
||||||
|
SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
SpiDrv::waitResponseCmd(GET_CURR_BSSID_CMD, PARAM_NUMS_1, _bssid, &_dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return _bssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t WiFiDrv::getCurrentRSSI()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_CURR_RSSI_CMD, PARAM_NUMS_1);
|
||||||
|
|
||||||
|
uint8_t _dummy = DUMMY_DATA;
|
||||||
|
SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
int32_t rssi = 0;
|
||||||
|
SpiDrv::waitResponseCmd(GET_CURR_RSSI_CMD, PARAM_NUMS_1, (uint8_t*)&rssi, &_dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return rssi;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiDrv::getCurrentEncryptionType()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_CURR_ENCT_CMD, PARAM_NUMS_1);
|
||||||
|
|
||||||
|
uint8_t _dummy = DUMMY_DATA;
|
||||||
|
SpiDrv::sendParam(&_dummy, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t dataLen = 0;
|
||||||
|
uint8_t encType = 0;
|
||||||
|
SpiDrv::waitResponseCmd(GET_CURR_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)&encType, &dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return encType;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t WiFiDrv::startScanNetworks()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(START_SCAN_NETWORKS, PARAM_NUMS_0);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
|
||||||
|
if (!SpiDrv::waitResponseCmd(START_SCAN_NETWORKS, PARAM_NUMS_1, &_data, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
_data = WL_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return (_data == WL_FAILURE)? _data : WL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t WiFiDrv::getScanNetworks()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(SCAN_NETWORKS, PARAM_NUMS_0);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t ssidListNum = 0;
|
||||||
|
SpiDrv::waitResponse(SCAN_NETWORKS, &ssidListNum, (uint8_t**)_networkSsid, WL_NETWORKS_LIST_MAXNUM);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return ssidListNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* WiFiDrv::getSSIDNetoworks(uint8_t networkItem)
|
||||||
|
{
|
||||||
|
if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return _networkSsid[networkItem];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiDrv::getEncTypeNetowrks(uint8_t networkItem)
|
||||||
|
{
|
||||||
|
if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_IDX_ENCT_CMD, PARAM_NUMS_1);
|
||||||
|
|
||||||
|
SpiDrv::sendParam(&networkItem, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t dataLen = 0;
|
||||||
|
uint8_t encType = 0;
|
||||||
|
SpiDrv::waitResponseCmd(GET_IDX_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)&encType, &dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return encType;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t WiFiDrv::getRSSINetoworks(uint8_t networkItem)
|
||||||
|
{
|
||||||
|
if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
|
||||||
|
return NULL;
|
||||||
|
int32_t networkRssi = 0;
|
||||||
|
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_IDX_RSSI_CMD, PARAM_NUMS_1);
|
||||||
|
|
||||||
|
SpiDrv::sendParam(&networkItem, 1, LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t dataLen = 0;
|
||||||
|
SpiDrv::waitResponseCmd(GET_IDX_RSSI_CMD, PARAM_NUMS_1, (uint8_t*)&networkRssi, &dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return networkRssi;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiDrv::reqHostByName(const char* aHostname)
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(REQ_HOST_BY_NAME_CMD, PARAM_NUMS_1);
|
||||||
|
SpiDrv::sendParam((uint8_t*)aHostname, strlen(aHostname), LAST_PARAM);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _data = 0;
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
uint8_t result = SpiDrv::waitResponseCmd(REQ_HOST_BY_NAME_CMD, PARAM_NUMS_1, &_data, &_dataLen);
|
||||||
|
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiDrv::getHostByName(IPAddress& aResult)
|
||||||
|
{
|
||||||
|
uint8_t _ipAddr[WL_IPV4_LENGTH];
|
||||||
|
IPAddress dummy(0xFF,0xFF,0xFF,0xFF);
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_HOST_BY_NAME_CMD, PARAM_NUMS_0);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(GET_HOST_BY_NAME_CMD, PARAM_NUMS_1, _ipAddr, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}else{
|
||||||
|
aResult = _ipAddr;
|
||||||
|
result = (aResult != dummy);
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WiFiDrv::getHostByName(const char* aHostname, IPAddress& aResult)
|
||||||
|
{
|
||||||
|
uint8_t retry = 10;
|
||||||
|
if (reqHostByName(aHostname))
|
||||||
|
{
|
||||||
|
while(!getHostByName(aResult) && --retry > 0)
|
||||||
|
{
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (retry>0);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* WiFiDrv::getFwVersion()
|
||||||
|
{
|
||||||
|
WAIT_FOR_SLAVE_SELECT();
|
||||||
|
// Send Command
|
||||||
|
SpiDrv::sendCmd(GET_FW_VERSION_CMD, PARAM_NUMS_0);
|
||||||
|
|
||||||
|
//Wait the reply elaboration
|
||||||
|
SpiDrv::waitForSlaveReady();
|
||||||
|
|
||||||
|
// Wait for reply
|
||||||
|
uint8_t _dataLen = 0;
|
||||||
|
if (!SpiDrv::waitResponseCmd(GET_FW_VERSION_CMD, PARAM_NUMS_1, (uint8_t*)fwVersion, &_dataLen))
|
||||||
|
{
|
||||||
|
WARN("error waitResponse");
|
||||||
|
}
|
||||||
|
SpiDrv::spiSlaveDeselect();
|
||||||
|
return fwVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFiDrv wiFiDrv;
|
267
WiFi/utility/wifi_drv.h
Normal file
267
WiFi/utility/wifi_drv.h
Normal file
@ -0,0 +1,267 @@
|
|||||||
|
/*
|
||||||
|
wifi_drv.h - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino. 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 WiFi_Drv_h
|
||||||
|
#define WiFi_Drv_h
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "utility/wifi_spi.h"
|
||||||
|
#include "IPAddress.h"
|
||||||
|
#include "WiFiUdp.h"
|
||||||
|
|
||||||
|
// Key index length
|
||||||
|
#define KEY_IDX_LEN 1
|
||||||
|
// 5 secs of delay to have the connection established
|
||||||
|
#define WL_DELAY_START_CONNECTION 5000
|
||||||
|
// firmware version string length
|
||||||
|
#define WL_FW_VER_LENGTH 6
|
||||||
|
|
||||||
|
class WiFiDrv
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// settings of requested network
|
||||||
|
static char _networkSsid[WL_NETWORKS_LIST_MAXNUM][WL_SSID_MAX_LENGTH];
|
||||||
|
static int32_t _networkRssi[WL_NETWORKS_LIST_MAXNUM];
|
||||||
|
static uint8_t _networkEncr[WL_NETWORKS_LIST_MAXNUM];
|
||||||
|
|
||||||
|
// firmware version string in the format a.b.c
|
||||||
|
static char fwVersion[WL_FW_VER_LENGTH];
|
||||||
|
|
||||||
|
// settings of current selected network
|
||||||
|
static char _ssid[WL_SSID_MAX_LENGTH];
|
||||||
|
static uint8_t _bssid[WL_MAC_ADDR_LENGTH];
|
||||||
|
static uint8_t _mac[WL_MAC_ADDR_LENGTH];
|
||||||
|
static uint8_t _localIp[WL_IPV4_LENGTH];
|
||||||
|
static uint8_t _subnetMask[WL_IPV4_LENGTH];
|
||||||
|
static uint8_t _gatewayIp[WL_IPV4_LENGTH];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get network Data information
|
||||||
|
*/
|
||||||
|
static void getNetworkData(uint8_t *ip, uint8_t *mask, uint8_t *gwip);
|
||||||
|
|
||||||
|
static uint8_t reqHostByName(const char* aHostname);
|
||||||
|
|
||||||
|
static int getHostByName(IPAddress& aResult);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get remote Data information on UDP socket
|
||||||
|
*/
|
||||||
|
static void getRemoteData(uint8_t sock, uint8_t *ip, uint8_t *port);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Driver initialization
|
||||||
|
*/
|
||||||
|
static void wifiDriverInit();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the desired network which the connection manager should try to
|
||||||
|
* connect to.
|
||||||
|
*
|
||||||
|
* The ssid of the desired network should be specified.
|
||||||
|
*
|
||||||
|
* param ssid: The ssid of the desired network.
|
||||||
|
* param ssid_len: Lenght of ssid string.
|
||||||
|
* return: WL_SUCCESS or WL_FAILURE
|
||||||
|
*/
|
||||||
|
static int8_t wifiSetNetwork(char* ssid, uint8_t ssid_len);
|
||||||
|
|
||||||
|
/* Start Wifi connection with passphrase
|
||||||
|
* the most secure supported mode will be automatically selected
|
||||||
|
*
|
||||||
|
* param ssid: Pointer to the SSID string.
|
||||||
|
* param ssid_len: Lenght of ssid string.
|
||||||
|
* param passphrase: Passphrase. Valid characters in a passphrase
|
||||||
|
* must be between ASCII 32-126 (decimal).
|
||||||
|
* param len: Lenght of passphrase string.
|
||||||
|
* return: WL_SUCCESS or WL_FAILURE
|
||||||
|
*/
|
||||||
|
static int8_t wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len);
|
||||||
|
|
||||||
|
/* Start Wifi connection with WEP encryption.
|
||||||
|
* Configure a key into the device. The key type (WEP-40, WEP-104)
|
||||||
|
* is determined by the size of the key (5 bytes for WEP-40, 13 bytes for WEP-104).
|
||||||
|
*
|
||||||
|
* param ssid: Pointer to the SSID string.
|
||||||
|
* param ssid_len: Lenght of ssid string.
|
||||||
|
* param key_idx: The key index to set. Valid values are 0-3.
|
||||||
|
* param key: Key input buffer.
|
||||||
|
* param len: Lenght of key string.
|
||||||
|
* return: WL_SUCCESS or WL_FAILURE
|
||||||
|
*/
|
||||||
|
static int8_t wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len);
|
||||||
|
|
||||||
|
/* Set ip configuration disabling dhcp client
|
||||||
|
*
|
||||||
|
* param validParams: set the number of parameters that we want to change
|
||||||
|
* i.e. validParams = 1 means that we'll change only ip address
|
||||||
|
* validParams = 3 means that we'll change ip address, gateway and netmask
|
||||||
|
* param local_ip: Static ip configuration
|
||||||
|
* param gateway: Static gateway configuration
|
||||||
|
* param subnet: Static subnet mask configuration
|
||||||
|
*/
|
||||||
|
static void config(uint8_t validParams, uint32_t local_ip, uint32_t gateway, uint32_t subnet);
|
||||||
|
|
||||||
|
/* Set DNS ip configuration
|
||||||
|
*
|
||||||
|
* param validParams: set the number of parameters that we want to change
|
||||||
|
* i.e. validParams = 1 means that we'll change only dns_server1
|
||||||
|
* validParams = 2 means that we'll change dns_server1 and dns_server2
|
||||||
|
* param dns_server1: Static DNS server1 configuration
|
||||||
|
* param dns_server2: Static DNS server2 configuration
|
||||||
|
*/
|
||||||
|
static void setDNS(uint8_t validParams, uint32_t dns_server1, uint32_t dns_server2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Disconnect from the network
|
||||||
|
*
|
||||||
|
* return: WL_SUCCESS or WL_FAILURE
|
||||||
|
*/
|
||||||
|
static int8_t disconnect();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Disconnect from the network
|
||||||
|
*
|
||||||
|
* return: one value of wl_status_t enum
|
||||||
|
*/
|
||||||
|
static uint8_t getConnectionStatus();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the interface MAC address.
|
||||||
|
*
|
||||||
|
* return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
|
||||||
|
*/
|
||||||
|
static uint8_t* getMacAddress();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the interface IP address.
|
||||||
|
*
|
||||||
|
* return: copy the ip address value in IPAddress object
|
||||||
|
*/
|
||||||
|
static void getIpAddress(IPAddress& ip);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the interface subnet mask address.
|
||||||
|
*
|
||||||
|
* return: copy the subnet mask address value in IPAddress object
|
||||||
|
*/
|
||||||
|
static void getSubnetMask(IPAddress& mask);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the gateway ip address.
|
||||||
|
*
|
||||||
|
* return: copy the gateway ip address value in IPAddress object
|
||||||
|
*/
|
||||||
|
static void getGatewayIP(IPAddress& ip);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the current SSID associated with the network
|
||||||
|
*
|
||||||
|
* return: ssid string
|
||||||
|
*/
|
||||||
|
static char* getCurrentSSID();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the current BSSID associated with the network.
|
||||||
|
* It is the MAC address of the Access Point
|
||||||
|
*
|
||||||
|
* return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
|
||||||
|
*/
|
||||||
|
static uint8_t* getCurrentBSSID();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the current RSSI /Received Signal Strength in dBm)
|
||||||
|
* associated with the network
|
||||||
|
*
|
||||||
|
* return: signed value
|
||||||
|
*/
|
||||||
|
static int32_t getCurrentRSSI();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the Encryption Type associated with the network
|
||||||
|
*
|
||||||
|
* return: one value of wl_enc_type enum
|
||||||
|
*/
|
||||||
|
static uint8_t getCurrentEncryptionType();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Start scan WiFi networks available
|
||||||
|
*
|
||||||
|
* return: Number of discovered networks
|
||||||
|
*/
|
||||||
|
static int8_t startScanNetworks();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the networks available
|
||||||
|
*
|
||||||
|
* return: Number of discovered networks
|
||||||
|
*/
|
||||||
|
static uint8_t getScanNetworks();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the SSID discovered during the network scan.
|
||||||
|
*
|
||||||
|
* param networkItem: specify from which network item want to get the information
|
||||||
|
*
|
||||||
|
* return: ssid string of the specified item on the networks scanned list
|
||||||
|
*/
|
||||||
|
static char* getSSIDNetoworks(uint8_t networkItem);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the RSSI of the networks discovered during the scanNetworks
|
||||||
|
*
|
||||||
|
* param networkItem: specify from which network item want to get the information
|
||||||
|
*
|
||||||
|
* return: signed value of RSSI of the specified item on the networks scanned list
|
||||||
|
*/
|
||||||
|
static int32_t getRSSINetoworks(uint8_t networkItem);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the encryption type of the networks discovered during the scanNetworks
|
||||||
|
*
|
||||||
|
* param networkItem: specify from which network item want to get the information
|
||||||
|
*
|
||||||
|
* return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
|
||||||
|
*/
|
||||||
|
static uint8_t getEncTypeNetowrks(uint8_t networkItem);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
static int getHostByName(const char* aHostname, IPAddress& aResult);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the firmware version
|
||||||
|
* result: version as string with this format a.b.c
|
||||||
|
*/
|
||||||
|
static char* getFwVersion();
|
||||||
|
|
||||||
|
friend class WiFiUDP;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
extern WiFiDrv wiFiDrv;
|
||||||
|
|
||||||
|
#endif
|
173
WiFi/utility/wifi_spi.h
Normal file
173
WiFi/utility/wifi_spi.h
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
/*
|
||||||
|
wifi_spi.h - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino. 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 WiFi_Spi_h
|
||||||
|
#define WiFi_Spi_h
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "utility/wl_definitions.h"
|
||||||
|
|
||||||
|
#define CMD_FLAG 0
|
||||||
|
#define REPLY_FLAG 1<<7
|
||||||
|
#define DATA_FLAG 0x40
|
||||||
|
|
||||||
|
#define WIFI_SPI_ACK 1
|
||||||
|
#define WIFI_SPI_ERR 0xFF
|
||||||
|
|
||||||
|
#define TIMEOUT_CHAR 1000
|
||||||
|
|
||||||
|
//#define MAX_SOCK_NUM 4 /**< Maxmium number of socket */
|
||||||
|
#define NO_SOCKET_AVAIL 255
|
||||||
|
|
||||||
|
#define START_CMD 0xE0
|
||||||
|
#define END_CMD 0xEE
|
||||||
|
#define ERR_CMD 0xEF
|
||||||
|
#define CMD_POS 1 // Position of Command OpCode on SPI stream
|
||||||
|
#define PARAM_LEN_POS 2 // Position of Param len on SPI stream
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SET_NET_CMD = 0x10,
|
||||||
|
SET_PASSPHRASE_CMD = 0x11,
|
||||||
|
SET_KEY_CMD = 0x12,
|
||||||
|
TEST_CMD = 0x13,
|
||||||
|
SET_IP_CONFIG_CMD = 0x14,
|
||||||
|
SET_DNS_CONFIG_CMD = 0x15,
|
||||||
|
|
||||||
|
GET_CONN_STATUS_CMD = 0x20,
|
||||||
|
GET_IPADDR_CMD = 0x21,
|
||||||
|
GET_MACADDR_CMD = 0x22,
|
||||||
|
GET_CURR_SSID_CMD = 0x23,
|
||||||
|
GET_CURR_BSSID_CMD = 0x24,
|
||||||
|
GET_CURR_RSSI_CMD = 0x25,
|
||||||
|
GET_CURR_ENCT_CMD = 0x26,
|
||||||
|
SCAN_NETWORKS = 0x27,
|
||||||
|
START_SERVER_TCP_CMD= 0x28,
|
||||||
|
GET_STATE_TCP_CMD = 0x29,
|
||||||
|
DATA_SENT_TCP_CMD = 0x2A,
|
||||||
|
AVAIL_DATA_TCP_CMD = 0x2B,
|
||||||
|
GET_DATA_TCP_CMD = 0x2C,
|
||||||
|
START_CLIENT_TCP_CMD= 0x2D,
|
||||||
|
STOP_CLIENT_TCP_CMD = 0x2E,
|
||||||
|
GET_CLIENT_STATE_TCP_CMD= 0x2F,
|
||||||
|
DISCONNECT_CMD = 0x30,
|
||||||
|
GET_IDX_SSID_CMD = 0x31,
|
||||||
|
GET_IDX_RSSI_CMD = 0x32,
|
||||||
|
GET_IDX_ENCT_CMD = 0x33,
|
||||||
|
REQ_HOST_BY_NAME_CMD= 0x34,
|
||||||
|
GET_HOST_BY_NAME_CMD= 0x35,
|
||||||
|
START_SCAN_NETWORKS = 0x36,
|
||||||
|
GET_FW_VERSION_CMD = 0x37,
|
||||||
|
GET_TEST_CMD = 0x38,
|
||||||
|
SEND_DATA_UDP_CMD = 0x39,
|
||||||
|
GET_REMOTE_DATA_CMD = 0x3A,
|
||||||
|
|
||||||
|
// All command with DATA_FLAG 0x40 send a 16bit Len
|
||||||
|
|
||||||
|
SEND_DATA_TCP_CMD = 0x44,
|
||||||
|
GET_DATABUF_TCP_CMD = 0x45,
|
||||||
|
INSERT_DATABUF_CMD = 0x46,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum wl_tcp_state {
|
||||||
|
CLOSED = 0,
|
||||||
|
LISTEN = 1,
|
||||||
|
SYN_SENT = 2,
|
||||||
|
SYN_RCVD = 3,
|
||||||
|
ESTABLISHED = 4,
|
||||||
|
FIN_WAIT_1 = 5,
|
||||||
|
FIN_WAIT_2 = 6,
|
||||||
|
CLOSE_WAIT = 7,
|
||||||
|
CLOSING = 8,
|
||||||
|
LAST_ACK = 9,
|
||||||
|
TIME_WAIT = 10
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum numParams{
|
||||||
|
PARAM_NUMS_0,
|
||||||
|
PARAM_NUMS_1,
|
||||||
|
PARAM_NUMS_2,
|
||||||
|
PARAM_NUMS_3,
|
||||||
|
PARAM_NUMS_4,
|
||||||
|
PARAM_NUMS_5,
|
||||||
|
MAX_PARAM_NUMS
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MAX_PARAMS MAX_PARAM_NUMS-1
|
||||||
|
#define PARAM_LEN_SIZE 1
|
||||||
|
|
||||||
|
typedef struct __attribute__((__packed__))
|
||||||
|
{
|
||||||
|
uint8_t paramLen;
|
||||||
|
char* param;
|
||||||
|
}tParam;
|
||||||
|
|
||||||
|
typedef struct __attribute__((__packed__))
|
||||||
|
{
|
||||||
|
uint16_t dataLen;
|
||||||
|
char* data;
|
||||||
|
}tDataParam;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct __attribute__((__packed__))
|
||||||
|
{
|
||||||
|
unsigned char cmd;
|
||||||
|
unsigned char tcmd;
|
||||||
|
unsigned char nParam;
|
||||||
|
tParam params[MAX_PARAMS];
|
||||||
|
}tSpiMsg;
|
||||||
|
|
||||||
|
typedef struct __attribute__((__packed__))
|
||||||
|
{
|
||||||
|
unsigned char cmd;
|
||||||
|
unsigned char tcmd;
|
||||||
|
unsigned char nParam;
|
||||||
|
tDataParam params[MAX_PARAMS];
|
||||||
|
}tSpiMsgData;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct __attribute__((__packed__))
|
||||||
|
{
|
||||||
|
unsigned char cmd;
|
||||||
|
unsigned char tcmd;
|
||||||
|
//unsigned char totLen;
|
||||||
|
unsigned char nParam;
|
||||||
|
}tSpiHdr;
|
||||||
|
|
||||||
|
typedef struct __attribute__((__packed__))
|
||||||
|
{
|
||||||
|
uint8_t paramLen;
|
||||||
|
uint32_t param;
|
||||||
|
}tLongParam;
|
||||||
|
|
||||||
|
typedef struct __attribute__((__packed__))
|
||||||
|
{
|
||||||
|
uint8_t paramLen;
|
||||||
|
uint16_t param;
|
||||||
|
}tIntParam;
|
||||||
|
|
||||||
|
typedef struct __attribute__((__packed__))
|
||||||
|
{
|
||||||
|
uint8_t paramLen;
|
||||||
|
uint8_t param;
|
||||||
|
}tByteParam;
|
||||||
|
|
||||||
|
#endif
|
72
WiFi/utility/wl_definitions.h
Normal file
72
WiFi/utility/wl_definitions.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
wl_definitions.h - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino. 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
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* wl_definitions.h
|
||||||
|
*
|
||||||
|
* Created on: Mar 6, 2011
|
||||||
|
* Author: dlafauci
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WL_DEFINITIONS_H_
|
||||||
|
#define WL_DEFINITIONS_H_
|
||||||
|
|
||||||
|
// Maximum size of a SSID
|
||||||
|
#define WL_SSID_MAX_LENGTH 32
|
||||||
|
// Length of passphrase. Valid lengths are 8-63.
|
||||||
|
#define WL_WPA_KEY_MAX_LENGTH 63
|
||||||
|
// Length of key in bytes. Valid values are 5 and 13.
|
||||||
|
#define WL_WEP_KEY_MAX_LENGTH 13
|
||||||
|
// Size of a MAC-address or BSSID
|
||||||
|
#define WL_MAC_ADDR_LENGTH 6
|
||||||
|
// Size of a MAC-address or BSSID
|
||||||
|
#define WL_IPV4_LENGTH 4
|
||||||
|
// Maximum size of a SSID list
|
||||||
|
#define WL_NETWORKS_LIST_MAXNUM 10
|
||||||
|
// Maxmium number of socket
|
||||||
|
#define MAX_SOCK_NUM 4
|
||||||
|
// Socket not available constant
|
||||||
|
#define SOCK_NOT_AVAIL 255
|
||||||
|
// Default state value for Wifi state field
|
||||||
|
#define NA_STATE -1
|
||||||
|
//Maximum number of attempts to establish wifi connection
|
||||||
|
#define WL_MAX_ATTEMPT_CONNECTION 10
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
WL_NO_SHIELD = 255,
|
||||||
|
WL_IDLE_STATUS = 0,
|
||||||
|
WL_NO_SSID_AVAIL,
|
||||||
|
WL_SCAN_COMPLETED,
|
||||||
|
WL_CONNECTED,
|
||||||
|
WL_CONNECT_FAILED,
|
||||||
|
WL_CONNECTION_LOST,
|
||||||
|
WL_DISCONNECTED
|
||||||
|
} wl_status_t;
|
||||||
|
|
||||||
|
/* Encryption modes */
|
||||||
|
enum wl_enc_type { /* Values map to 802.11 encryption suites... */
|
||||||
|
ENC_TYPE_WEP = 5,
|
||||||
|
ENC_TYPE_TKIP = 2,
|
||||||
|
ENC_TYPE_CCMP = 4,
|
||||||
|
/* ... except these two, 7 and 8 are reserved in 802.11-2007 */
|
||||||
|
ENC_TYPE_NONE = 7,
|
||||||
|
ENC_TYPE_AUTO = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* WL_DEFINITIONS_H_ */
|
49
WiFi/utility/wl_types.h
Normal file
49
WiFi/utility/wl_types.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
wl_types.h - Library for Arduino Wifi shield.
|
||||||
|
Copyright (c) 2011-2014 Arduino. 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
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* wl_types.h
|
||||||
|
*
|
||||||
|
* Created on: Jul 30, 2010
|
||||||
|
* Author: dlafauci
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _WL_TYPES_H_
|
||||||
|
#define _WL_TYPES_H_
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
WL_FAILURE = -1,
|
||||||
|
WL_SUCCESS = 1,
|
||||||
|
} wl_error_code_t;
|
||||||
|
|
||||||
|
/* Authentication modes */
|
||||||
|
enum wl_auth_mode {
|
||||||
|
AUTH_MODE_INVALID,
|
||||||
|
AUTH_MODE_AUTO,
|
||||||
|
AUTH_MODE_OPEN_SYSTEM,
|
||||||
|
AUTH_MODE_SHARED_KEY,
|
||||||
|
AUTH_MODE_WPA,
|
||||||
|
AUTH_MODE_WPA2,
|
||||||
|
AUTH_MODE_WPA_PSK,
|
||||||
|
AUTH_MODE_WPA2_PSK
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_WL_TYPES_H_
|
330
Wire/Wire.cpp
Normal file
330
Wire/Wire.cpp
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
/*
|
||||||
|
TwoWire.cpp - TWI/I2C library for Wiring & Arduino
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. 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
|
||||||
|
|
||||||
|
Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "utility/twi.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "Wire.h"
|
||||||
|
|
||||||
|
// Initialize Class Variables //////////////////////////////////////////////////
|
||||||
|
|
||||||
|
uint8_t TwoWire::rxBuffer[BUFFER_LENGTH];
|
||||||
|
uint8_t TwoWire::rxBufferIndex = 0;
|
||||||
|
uint8_t TwoWire::rxBufferLength = 0;
|
||||||
|
|
||||||
|
uint8_t TwoWire::txAddress = 0;
|
||||||
|
uint8_t TwoWire::txBuffer[BUFFER_LENGTH];
|
||||||
|
uint8_t TwoWire::txBufferIndex = 0;
|
||||||
|
uint8_t TwoWire::txBufferLength = 0;
|
||||||
|
|
||||||
|
uint8_t TwoWire::transmitting = 0;
|
||||||
|
void (*TwoWire::user_onRequest)(void);
|
||||||
|
void (*TwoWire::user_onReceive)(int);
|
||||||
|
|
||||||
|
// Constructors ////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TwoWire::TwoWire()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Public Methods //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TwoWire::begin(void)
|
||||||
|
{
|
||||||
|
rxBufferIndex = 0;
|
||||||
|
rxBufferLength = 0;
|
||||||
|
|
||||||
|
txBufferIndex = 0;
|
||||||
|
txBufferLength = 0;
|
||||||
|
|
||||||
|
twi_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwoWire::begin(uint8_t address)
|
||||||
|
{
|
||||||
|
twi_setAddress(address);
|
||||||
|
twi_attachSlaveTxEvent(onRequestService);
|
||||||
|
twi_attachSlaveRxEvent(onReceiveService);
|
||||||
|
begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwoWire::begin(int address)
|
||||||
|
{
|
||||||
|
begin((uint8_t)address);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwoWire::end(void)
|
||||||
|
{
|
||||||
|
twi_disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwoWire::setClock(uint32_t clock)
|
||||||
|
{
|
||||||
|
twi_setFrequency(clock);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint32_t iaddress, uint8_t isize, uint8_t sendStop)
|
||||||
|
{
|
||||||
|
if (isize > 0) {
|
||||||
|
// send internal address; this mode allows sending a repeated start to access
|
||||||
|
// some devices' internal registers. This function is executed by the hardware
|
||||||
|
// TWI module on other processors (for example Due's TWI_IADR and TWI_MMR registers)
|
||||||
|
|
||||||
|
beginTransmission(address);
|
||||||
|
|
||||||
|
// the maximum size of internal address is 3 bytes
|
||||||
|
if (isize > 3){
|
||||||
|
isize = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// write internal register address - most significant byte first
|
||||||
|
while (isize-- > 0)
|
||||||
|
write((uint8_t)(iaddress >> (isize*8)));
|
||||||
|
endTransmission(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// clamp to buffer length
|
||||||
|
if(quantity > BUFFER_LENGTH){
|
||||||
|
quantity = BUFFER_LENGTH;
|
||||||
|
}
|
||||||
|
// perform blocking read into buffer
|
||||||
|
uint8_t read = twi_readFrom(address, rxBuffer, quantity, sendStop);
|
||||||
|
// set rx buffer iterator vars
|
||||||
|
rxBufferIndex = 0;
|
||||||
|
rxBufferLength = read;
|
||||||
|
|
||||||
|
return read;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop) {
|
||||||
|
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint32_t)0, (uint8_t)0, (uint8_t)sendStop);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity)
|
||||||
|
{
|
||||||
|
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TwoWire::requestFrom(int address, int quantity)
|
||||||
|
{
|
||||||
|
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop)
|
||||||
|
{
|
||||||
|
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwoWire::beginTransmission(uint8_t address)
|
||||||
|
{
|
||||||
|
// indicate that we are transmitting
|
||||||
|
transmitting = 1;
|
||||||
|
// set address of targeted slave
|
||||||
|
txAddress = address;
|
||||||
|
// reset tx buffer iterator vars
|
||||||
|
txBufferIndex = 0;
|
||||||
|
txBufferLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwoWire::beginTransmission(int address)
|
||||||
|
{
|
||||||
|
beginTransmission((uint8_t)address);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Originally, 'endTransmission' was an f(void) function.
|
||||||
|
// It has been modified to take one parameter indicating
|
||||||
|
// whether or not a STOP should be performed on the bus.
|
||||||
|
// Calling endTransmission(false) allows a sketch to
|
||||||
|
// perform a repeated start.
|
||||||
|
//
|
||||||
|
// WARNING: Nothing in the library keeps track of whether
|
||||||
|
// the bus tenure has been properly ended with a STOP. It
|
||||||
|
// is very possible to leave the bus in a hung state if
|
||||||
|
// no call to endTransmission(true) is made. Some I2C
|
||||||
|
// devices will behave oddly if they do not see a STOP.
|
||||||
|
//
|
||||||
|
uint8_t TwoWire::endTransmission(uint8_t sendStop)
|
||||||
|
{
|
||||||
|
// transmit buffer (blocking)
|
||||||
|
uint8_t ret = twi_writeTo(txAddress, txBuffer, txBufferLength, 1, sendStop);
|
||||||
|
// reset tx buffer iterator vars
|
||||||
|
txBufferIndex = 0;
|
||||||
|
txBufferLength = 0;
|
||||||
|
// indicate that we are done transmitting
|
||||||
|
transmitting = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This provides backwards compatibility with the original
|
||||||
|
// definition, and expected behaviour, of endTransmission
|
||||||
|
//
|
||||||
|
uint8_t TwoWire::endTransmission(void)
|
||||||
|
{
|
||||||
|
return endTransmission(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// must be called in:
|
||||||
|
// slave tx event callback
|
||||||
|
// or after beginTransmission(address)
|
||||||
|
size_t TwoWire::write(uint8_t data)
|
||||||
|
{
|
||||||
|
if(transmitting){
|
||||||
|
// in master transmitter mode
|
||||||
|
// don't bother if buffer is full
|
||||||
|
if(txBufferLength >= BUFFER_LENGTH){
|
||||||
|
setWriteError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// put byte in tx buffer
|
||||||
|
txBuffer[txBufferIndex] = data;
|
||||||
|
++txBufferIndex;
|
||||||
|
// update amount in buffer
|
||||||
|
txBufferLength = txBufferIndex;
|
||||||
|
}else{
|
||||||
|
// in slave send mode
|
||||||
|
// reply to master
|
||||||
|
twi_transmit(&data, 1);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// must be called in:
|
||||||
|
// slave tx event callback
|
||||||
|
// or after beginTransmission(address)
|
||||||
|
size_t TwoWire::write(const uint8_t *data, size_t quantity)
|
||||||
|
{
|
||||||
|
if(transmitting){
|
||||||
|
// in master transmitter mode
|
||||||
|
for(size_t i = 0; i < quantity; ++i){
|
||||||
|
write(data[i]);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// in slave send mode
|
||||||
|
// reply to master
|
||||||
|
twi_transmit(data, quantity);
|
||||||
|
}
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
// must be called in:
|
||||||
|
// slave rx event callback
|
||||||
|
// or after requestFrom(address, numBytes)
|
||||||
|
int TwoWire::available(void)
|
||||||
|
{
|
||||||
|
return rxBufferLength - rxBufferIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
// must be called in:
|
||||||
|
// slave rx event callback
|
||||||
|
// or after requestFrom(address, numBytes)
|
||||||
|
int TwoWire::read(void)
|
||||||
|
{
|
||||||
|
int value = -1;
|
||||||
|
|
||||||
|
// get each successive byte on each call
|
||||||
|
if(rxBufferIndex < rxBufferLength){
|
||||||
|
value = rxBuffer[rxBufferIndex];
|
||||||
|
++rxBufferIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// must be called in:
|
||||||
|
// slave rx event callback
|
||||||
|
// or after requestFrom(address, numBytes)
|
||||||
|
int TwoWire::peek(void)
|
||||||
|
{
|
||||||
|
int value = -1;
|
||||||
|
|
||||||
|
if(rxBufferIndex < rxBufferLength){
|
||||||
|
value = rxBuffer[rxBufferIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwoWire::flush(void)
|
||||||
|
{
|
||||||
|
// XXX: to be implemented.
|
||||||
|
}
|
||||||
|
|
||||||
|
// behind the scenes function that is called when data is received
|
||||||
|
void TwoWire::onReceiveService(uint8_t* inBytes, int numBytes)
|
||||||
|
{
|
||||||
|
// don't bother if user hasn't registered a callback
|
||||||
|
if(!user_onReceive){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// don't bother if rx buffer is in use by a master requestFrom() op
|
||||||
|
// i know this drops data, but it allows for slight stupidity
|
||||||
|
// meaning, they may not have read all the master requestFrom() data yet
|
||||||
|
if(rxBufferIndex < rxBufferLength){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// copy twi rx buffer into local read buffer
|
||||||
|
// this enables new reads to happen in parallel
|
||||||
|
for(uint8_t i = 0; i < numBytes; ++i){
|
||||||
|
rxBuffer[i] = inBytes[i];
|
||||||
|
}
|
||||||
|
// set rx iterator vars
|
||||||
|
rxBufferIndex = 0;
|
||||||
|
rxBufferLength = numBytes;
|
||||||
|
// alert user program
|
||||||
|
user_onReceive(numBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// behind the scenes function that is called when data is requested
|
||||||
|
void TwoWire::onRequestService(void)
|
||||||
|
{
|
||||||
|
// don't bother if user hasn't registered a callback
|
||||||
|
if(!user_onRequest){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// reset tx buffer iterator vars
|
||||||
|
// !!! this will kill any pending pre-master sendTo() activity
|
||||||
|
txBufferIndex = 0;
|
||||||
|
txBufferLength = 0;
|
||||||
|
// alert user program
|
||||||
|
user_onRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
// sets function called on slave write
|
||||||
|
void TwoWire::onReceive( void (*function)(int) )
|
||||||
|
{
|
||||||
|
user_onReceive = function;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sets function called on slave read
|
||||||
|
void TwoWire::onRequest( void (*function)(void) )
|
||||||
|
{
|
||||||
|
user_onRequest = function;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preinstantiate Objects //////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TwoWire Wire = TwoWire();
|
||||||
|
|
85
Wire/Wire.h
Normal file
85
Wire/Wire.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
TwoWire.h - TWI/I2C library for Arduino & Wiring
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. 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
|
||||||
|
|
||||||
|
Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TwoWire_h
|
||||||
|
#define TwoWire_h
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "Stream.h"
|
||||||
|
|
||||||
|
#define BUFFER_LENGTH 32
|
||||||
|
|
||||||
|
// WIRE_HAS_END means Wire has end()
|
||||||
|
#define WIRE_HAS_END 1
|
||||||
|
|
||||||
|
class TwoWire : public Stream
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
static uint8_t rxBuffer[];
|
||||||
|
static uint8_t rxBufferIndex;
|
||||||
|
static uint8_t rxBufferLength;
|
||||||
|
|
||||||
|
static uint8_t txAddress;
|
||||||
|
static uint8_t txBuffer[];
|
||||||
|
static uint8_t txBufferIndex;
|
||||||
|
static uint8_t txBufferLength;
|
||||||
|
|
||||||
|
static uint8_t transmitting;
|
||||||
|
static void (*user_onRequest)(void);
|
||||||
|
static void (*user_onReceive)(int);
|
||||||
|
static void onRequestService(void);
|
||||||
|
static void onReceiveService(uint8_t*, int);
|
||||||
|
public:
|
||||||
|
TwoWire();
|
||||||
|
void begin();
|
||||||
|
void begin(uint8_t);
|
||||||
|
void begin(int);
|
||||||
|
void end();
|
||||||
|
void setClock(uint32_t);
|
||||||
|
void beginTransmission(uint8_t);
|
||||||
|
void beginTransmission(int);
|
||||||
|
uint8_t endTransmission(void);
|
||||||
|
uint8_t endTransmission(uint8_t);
|
||||||
|
uint8_t requestFrom(uint8_t, uint8_t);
|
||||||
|
uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
|
||||||
|
uint8_t requestFrom(uint8_t, uint8_t, uint32_t, uint8_t, uint8_t);
|
||||||
|
uint8_t requestFrom(int, int);
|
||||||
|
uint8_t requestFrom(int, int, int);
|
||||||
|
virtual size_t write(uint8_t);
|
||||||
|
virtual size_t write(const uint8_t *, size_t);
|
||||||
|
virtual int available(void);
|
||||||
|
virtual int read(void);
|
||||||
|
virtual int peek(void);
|
||||||
|
virtual void flush(void);
|
||||||
|
void onReceive( void (*)(int) );
|
||||||
|
void onRequest( void (*)(void) );
|
||||||
|
|
||||||
|
inline size_t write(unsigned long n) { return write((uint8_t)n); }
|
||||||
|
inline size_t write(long n) { return write((uint8_t)n); }
|
||||||
|
inline size_t write(unsigned int n) { return write((uint8_t)n); }
|
||||||
|
inline size_t write(int n) { return write((uint8_t)n); }
|
||||||
|
using Print::write;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern TwoWire Wire;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
561
Wire/utility/twi.c
Normal file
561
Wire/utility/twi.c
Normal file
@ -0,0 +1,561 @@
|
|||||||
|
/*
|
||||||
|
twi.c - TWI/I2C library for Wiring & Arduino
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. 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
|
||||||
|
|
||||||
|
Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <compat/twi.h>
|
||||||
|
#include "Arduino.h" // for digitalWrite
|
||||||
|
|
||||||
|
#ifndef cbi
|
||||||
|
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef sbi
|
||||||
|
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "pins_arduino.h"
|
||||||
|
#include "twi.h"
|
||||||
|
|
||||||
|
static volatile uint8_t twi_state;
|
||||||
|
static volatile uint8_t twi_slarw;
|
||||||
|
static volatile uint8_t twi_sendStop; // should the transaction end with a stop
|
||||||
|
static volatile uint8_t twi_inRepStart; // in the middle of a repeated start
|
||||||
|
|
||||||
|
static void (*twi_onSlaveTransmit)(void);
|
||||||
|
static void (*twi_onSlaveReceive)(uint8_t*, int);
|
||||||
|
|
||||||
|
static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH];
|
||||||
|
static volatile uint8_t twi_masterBufferIndex;
|
||||||
|
static volatile uint8_t twi_masterBufferLength;
|
||||||
|
|
||||||
|
static uint8_t twi_txBuffer[TWI_BUFFER_LENGTH];
|
||||||
|
static volatile uint8_t twi_txBufferIndex;
|
||||||
|
static volatile uint8_t twi_txBufferLength;
|
||||||
|
|
||||||
|
static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH];
|
||||||
|
static volatile uint8_t twi_rxBufferIndex;
|
||||||
|
|
||||||
|
static volatile uint8_t twi_error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_init
|
||||||
|
* Desc readys twi pins and sets twi bitrate
|
||||||
|
* Input none
|
||||||
|
* Output none
|
||||||
|
*/
|
||||||
|
void twi_init(void)
|
||||||
|
{
|
||||||
|
// initialize state
|
||||||
|
twi_state = TWI_READY;
|
||||||
|
twi_sendStop = true; // default value
|
||||||
|
twi_inRepStart = false;
|
||||||
|
|
||||||
|
// activate internal pullups for twi.
|
||||||
|
digitalWrite(SDA, 1);
|
||||||
|
digitalWrite(SCL, 1);
|
||||||
|
|
||||||
|
// initialize twi prescaler and bit rate
|
||||||
|
cbi(TWSR, TWPS0);
|
||||||
|
cbi(TWSR, TWPS1);
|
||||||
|
TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
|
||||||
|
|
||||||
|
/* twi bit rate formula from atmega128 manual pg 204
|
||||||
|
SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
|
||||||
|
note: TWBR should be 10 or higher for master mode
|
||||||
|
It is 72 for a 16mhz Wiring board with 100kHz TWI */
|
||||||
|
|
||||||
|
// enable twi module, acks, and twi interrupt
|
||||||
|
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_disable
|
||||||
|
* Desc disables twi pins
|
||||||
|
* Input none
|
||||||
|
* Output none
|
||||||
|
*/
|
||||||
|
void twi_disable(void)
|
||||||
|
{
|
||||||
|
// disable twi module, acks, and twi interrupt
|
||||||
|
TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
|
||||||
|
|
||||||
|
// deactivate internal pullups for twi.
|
||||||
|
digitalWrite(SDA, 0);
|
||||||
|
digitalWrite(SCL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_slaveInit
|
||||||
|
* Desc sets slave address and enables interrupt
|
||||||
|
* Input none
|
||||||
|
* Output none
|
||||||
|
*/
|
||||||
|
void twi_setAddress(uint8_t address)
|
||||||
|
{
|
||||||
|
// set twi slave address (skip over TWGCE bit)
|
||||||
|
TWAR = address << 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_setClock
|
||||||
|
* Desc sets twi bit rate
|
||||||
|
* Input Clock Frequency
|
||||||
|
* Output none
|
||||||
|
*/
|
||||||
|
void twi_setFrequency(uint32_t frequency)
|
||||||
|
{
|
||||||
|
TWBR = ((F_CPU / frequency) - 16) / 2;
|
||||||
|
|
||||||
|
/* twi bit rate formula from atmega128 manual pg 204
|
||||||
|
SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
|
||||||
|
note: TWBR should be 10 or higher for master mode
|
||||||
|
It is 72 for a 16mhz Wiring board with 100kHz TWI */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_readFrom
|
||||||
|
* Desc attempts to become twi bus master and read a
|
||||||
|
* series of bytes from a device on the bus
|
||||||
|
* Input address: 7bit i2c device address
|
||||||
|
* data: pointer to byte array
|
||||||
|
* length: number of bytes to read into array
|
||||||
|
* sendStop: Boolean indicating whether to send a stop at the end
|
||||||
|
* Output number of bytes read
|
||||||
|
*/
|
||||||
|
uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sendStop)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
// ensure data will fit into buffer
|
||||||
|
if(TWI_BUFFER_LENGTH < length){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait until twi is ready, become master receiver
|
||||||
|
while(TWI_READY != twi_state){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
twi_state = TWI_MRX;
|
||||||
|
twi_sendStop = sendStop;
|
||||||
|
// reset error state (0xFF.. no error occured)
|
||||||
|
twi_error = 0xFF;
|
||||||
|
|
||||||
|
// initialize buffer iteration vars
|
||||||
|
twi_masterBufferIndex = 0;
|
||||||
|
twi_masterBufferLength = length-1; // This is not intuitive, read on...
|
||||||
|
// On receive, the previously configured ACK/NACK setting is transmitted in
|
||||||
|
// response to the received byte before the interrupt is signalled.
|
||||||
|
// Therefor we must actually set NACK when the _next_ to last byte is
|
||||||
|
// received, causing that NACK to be sent in response to receiving the last
|
||||||
|
// expected byte of data.
|
||||||
|
|
||||||
|
// build sla+w, slave device address + w bit
|
||||||
|
twi_slarw = TW_READ;
|
||||||
|
twi_slarw |= address << 1;
|
||||||
|
|
||||||
|
if (true == twi_inRepStart) {
|
||||||
|
// if we're in the repeated start state, then we've already sent the start,
|
||||||
|
// (@@@ we hope), and the TWI statemachine is just waiting for the address byte.
|
||||||
|
// We need to remove ourselves from the repeated start state before we enable interrupts,
|
||||||
|
// since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning
|
||||||
|
// up. Also, don't enable the START interrupt. There may be one pending from the
|
||||||
|
// repeated start that we sent ourselves, and that would really confuse things.
|
||||||
|
twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
|
||||||
|
do {
|
||||||
|
TWDR = twi_slarw;
|
||||||
|
} while(TWCR & _BV(TWWC));
|
||||||
|
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// send start condition
|
||||||
|
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);
|
||||||
|
|
||||||
|
// wait for read operation to complete
|
||||||
|
while(TWI_MRX == twi_state){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (twi_masterBufferIndex < length)
|
||||||
|
length = twi_masterBufferIndex;
|
||||||
|
|
||||||
|
// copy twi buffer to data
|
||||||
|
for(i = 0; i < length; ++i){
|
||||||
|
data[i] = twi_masterBuffer[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_writeTo
|
||||||
|
* Desc attempts to become twi bus master and write a
|
||||||
|
* series of bytes to a device on the bus
|
||||||
|
* Input address: 7bit i2c device address
|
||||||
|
* data: pointer to byte array
|
||||||
|
* length: number of bytes in array
|
||||||
|
* wait: boolean indicating to wait for write or not
|
||||||
|
* sendStop: boolean indicating whether or not to send a stop at the end
|
||||||
|
* Output 0 .. success
|
||||||
|
* 1 .. length to long for buffer
|
||||||
|
* 2 .. address send, NACK received
|
||||||
|
* 3 .. data send, NACK received
|
||||||
|
* 4 .. other twi error (lost bus arbitration, bus error, ..)
|
||||||
|
*/
|
||||||
|
uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
// ensure data will fit into buffer
|
||||||
|
if(TWI_BUFFER_LENGTH < length){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait until twi is ready, become master transmitter
|
||||||
|
while(TWI_READY != twi_state){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
twi_state = TWI_MTX;
|
||||||
|
twi_sendStop = sendStop;
|
||||||
|
// reset error state (0xFF.. no error occured)
|
||||||
|
twi_error = 0xFF;
|
||||||
|
|
||||||
|
// initialize buffer iteration vars
|
||||||
|
twi_masterBufferIndex = 0;
|
||||||
|
twi_masterBufferLength = length;
|
||||||
|
|
||||||
|
// copy data to twi buffer
|
||||||
|
for(i = 0; i < length; ++i){
|
||||||
|
twi_masterBuffer[i] = data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// build sla+w, slave device address + w bit
|
||||||
|
twi_slarw = TW_WRITE;
|
||||||
|
twi_slarw |= address << 1;
|
||||||
|
|
||||||
|
// if we're in a repeated start, then we've already sent the START
|
||||||
|
// in the ISR. Don't do it again.
|
||||||
|
//
|
||||||
|
if (true == twi_inRepStart) {
|
||||||
|
// if we're in the repeated start state, then we've already sent the start,
|
||||||
|
// (@@@ we hope), and the TWI statemachine is just waiting for the address byte.
|
||||||
|
// We need to remove ourselves from the repeated start state before we enable interrupts,
|
||||||
|
// since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning
|
||||||
|
// up. Also, don't enable the START interrupt. There may be one pending from the
|
||||||
|
// repeated start that we sent outselves, and that would really confuse things.
|
||||||
|
twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
|
||||||
|
do {
|
||||||
|
TWDR = twi_slarw;
|
||||||
|
} while(TWCR & _BV(TWWC));
|
||||||
|
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// send start condition
|
||||||
|
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA); // enable INTs
|
||||||
|
|
||||||
|
// wait for write operation to complete
|
||||||
|
while(wait && (TWI_MTX == twi_state)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (twi_error == 0xFF)
|
||||||
|
return 0; // success
|
||||||
|
else if (twi_error == TW_MT_SLA_NACK)
|
||||||
|
return 2; // error: address send, nack received
|
||||||
|
else if (twi_error == TW_MT_DATA_NACK)
|
||||||
|
return 3; // error: data send, nack received
|
||||||
|
else
|
||||||
|
return 4; // other twi error
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_transmit
|
||||||
|
* Desc fills slave tx buffer with data
|
||||||
|
* must be called in slave tx event callback
|
||||||
|
* Input data: pointer to byte array
|
||||||
|
* length: number of bytes in array
|
||||||
|
* Output 1 length too long for buffer
|
||||||
|
* 2 not slave transmitter
|
||||||
|
* 0 ok
|
||||||
|
*/
|
||||||
|
uint8_t twi_transmit(const uint8_t* data, uint8_t length)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
// ensure data will fit into buffer
|
||||||
|
if(TWI_BUFFER_LENGTH < (twi_txBufferLength+length)){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure we are currently a slave transmitter
|
||||||
|
if(TWI_STX != twi_state){
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set length and copy data into tx buffer
|
||||||
|
for(i = 0; i < length; ++i){
|
||||||
|
twi_txBuffer[twi_txBufferLength+i] = data[i];
|
||||||
|
}
|
||||||
|
twi_txBufferLength += length;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_attachSlaveRxEvent
|
||||||
|
* Desc sets function called before a slave read operation
|
||||||
|
* Input function: callback function to use
|
||||||
|
* Output none
|
||||||
|
*/
|
||||||
|
void twi_attachSlaveRxEvent( void (*function)(uint8_t*, int) )
|
||||||
|
{
|
||||||
|
twi_onSlaveReceive = function;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_attachSlaveTxEvent
|
||||||
|
* Desc sets function called before a slave write operation
|
||||||
|
* Input function: callback function to use
|
||||||
|
* Output none
|
||||||
|
*/
|
||||||
|
void twi_attachSlaveTxEvent( void (*function)(void) )
|
||||||
|
{
|
||||||
|
twi_onSlaveTransmit = function;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_reply
|
||||||
|
* Desc sends byte or readys receive line
|
||||||
|
* Input ack: byte indicating to ack or to nack
|
||||||
|
* Output none
|
||||||
|
*/
|
||||||
|
void twi_reply(uint8_t ack)
|
||||||
|
{
|
||||||
|
// transmit master read ready signal, with or without ack
|
||||||
|
if(ack){
|
||||||
|
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
|
||||||
|
}else{
|
||||||
|
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_stop
|
||||||
|
* Desc relinquishes bus master status
|
||||||
|
* Input none
|
||||||
|
* Output none
|
||||||
|
*/
|
||||||
|
void twi_stop(void)
|
||||||
|
{
|
||||||
|
// send stop condition
|
||||||
|
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
|
||||||
|
|
||||||
|
// wait for stop condition to be exectued on bus
|
||||||
|
// TWINT is not set after a stop condition!
|
||||||
|
while(TWCR & _BV(TWSTO)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update twi state
|
||||||
|
twi_state = TWI_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function twi_releaseBus
|
||||||
|
* Desc releases bus control
|
||||||
|
* Input none
|
||||||
|
* Output none
|
||||||
|
*/
|
||||||
|
void twi_releaseBus(void)
|
||||||
|
{
|
||||||
|
// release bus
|
||||||
|
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
|
||||||
|
|
||||||
|
// update twi state
|
||||||
|
twi_state = TWI_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(TWI_vect)
|
||||||
|
{
|
||||||
|
switch(TW_STATUS){
|
||||||
|
// All Master
|
||||||
|
case TW_START: // sent start condition
|
||||||
|
case TW_REP_START: // sent repeated start condition
|
||||||
|
// copy device address and r/w bit to output register and ack
|
||||||
|
TWDR = twi_slarw;
|
||||||
|
twi_reply(1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Master Transmitter
|
||||||
|
case TW_MT_SLA_ACK: // slave receiver acked address
|
||||||
|
case TW_MT_DATA_ACK: // slave receiver acked data
|
||||||
|
// if there is data to send, send it, otherwise stop
|
||||||
|
if(twi_masterBufferIndex < twi_masterBufferLength){
|
||||||
|
// copy data to output register and ack
|
||||||
|
TWDR = twi_masterBuffer[twi_masterBufferIndex++];
|
||||||
|
twi_reply(1);
|
||||||
|
}else{
|
||||||
|
if (twi_sendStop)
|
||||||
|
twi_stop();
|
||||||
|
else {
|
||||||
|
twi_inRepStart = true; // we're gonna send the START
|
||||||
|
// don't enable the interrupt. We'll generate the start, but we
|
||||||
|
// avoid handling the interrupt until we're in the next transaction,
|
||||||
|
// at the point where we would normally issue the start.
|
||||||
|
TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
|
||||||
|
twi_state = TWI_READY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TW_MT_SLA_NACK: // address sent, nack received
|
||||||
|
twi_error = TW_MT_SLA_NACK;
|
||||||
|
twi_stop();
|
||||||
|
break;
|
||||||
|
case TW_MT_DATA_NACK: // data sent, nack received
|
||||||
|
twi_error = TW_MT_DATA_NACK;
|
||||||
|
twi_stop();
|
||||||
|
break;
|
||||||
|
case TW_MT_ARB_LOST: // lost bus arbitration
|
||||||
|
twi_error = TW_MT_ARB_LOST;
|
||||||
|
twi_releaseBus();
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Master Receiver
|
||||||
|
case TW_MR_DATA_ACK: // data received, ack sent
|
||||||
|
// put byte into buffer
|
||||||
|
twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
|
||||||
|
case TW_MR_SLA_ACK: // address sent, ack received
|
||||||
|
// ack if more bytes are expected, otherwise nack
|
||||||
|
if(twi_masterBufferIndex < twi_masterBufferLength){
|
||||||
|
twi_reply(1);
|
||||||
|
}else{
|
||||||
|
twi_reply(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TW_MR_DATA_NACK: // data received, nack sent
|
||||||
|
// put final byte into buffer
|
||||||
|
twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
|
||||||
|
if (twi_sendStop)
|
||||||
|
twi_stop();
|
||||||
|
else {
|
||||||
|
twi_inRepStart = true; // we're gonna send the START
|
||||||
|
// don't enable the interrupt. We'll generate the start, but we
|
||||||
|
// avoid handling the interrupt until we're in the next transaction,
|
||||||
|
// at the point where we would normally issue the start.
|
||||||
|
TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
|
||||||
|
twi_state = TWI_READY;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TW_MR_SLA_NACK: // address sent, nack received
|
||||||
|
twi_stop();
|
||||||
|
break;
|
||||||
|
// TW_MR_ARB_LOST handled by TW_MT_ARB_LOST case
|
||||||
|
|
||||||
|
// Slave Receiver
|
||||||
|
case TW_SR_SLA_ACK: // addressed, returned ack
|
||||||
|
case TW_SR_GCALL_ACK: // addressed generally, returned ack
|
||||||
|
case TW_SR_ARB_LOST_SLA_ACK: // lost arbitration, returned ack
|
||||||
|
case TW_SR_ARB_LOST_GCALL_ACK: // lost arbitration, returned ack
|
||||||
|
// enter slave receiver mode
|
||||||
|
twi_state = TWI_SRX;
|
||||||
|
// indicate that rx buffer can be overwritten and ack
|
||||||
|
twi_rxBufferIndex = 0;
|
||||||
|
twi_reply(1);
|
||||||
|
break;
|
||||||
|
case TW_SR_DATA_ACK: // data received, returned ack
|
||||||
|
case TW_SR_GCALL_DATA_ACK: // data received generally, returned ack
|
||||||
|
// if there is still room in the rx buffer
|
||||||
|
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
|
||||||
|
// put byte in buffer and ack
|
||||||
|
twi_rxBuffer[twi_rxBufferIndex++] = TWDR;
|
||||||
|
twi_reply(1);
|
||||||
|
}else{
|
||||||
|
// otherwise nack
|
||||||
|
twi_reply(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TW_SR_STOP: // stop or repeated start condition received
|
||||||
|
// ack future responses and leave slave receiver state
|
||||||
|
twi_releaseBus();
|
||||||
|
// put a null char after data if there's room
|
||||||
|
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
|
||||||
|
twi_rxBuffer[twi_rxBufferIndex] = '\0';
|
||||||
|
}
|
||||||
|
// callback to user defined callback
|
||||||
|
twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
|
||||||
|
// since we submit rx buffer to "wire" library, we can reset it
|
||||||
|
twi_rxBufferIndex = 0;
|
||||||
|
break;
|
||||||
|
case TW_SR_DATA_NACK: // data received, returned nack
|
||||||
|
case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack
|
||||||
|
// nack back at master
|
||||||
|
twi_reply(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Slave Transmitter
|
||||||
|
case TW_ST_SLA_ACK: // addressed, returned ack
|
||||||
|
case TW_ST_ARB_LOST_SLA_ACK: // arbitration lost, returned ack
|
||||||
|
// enter slave transmitter mode
|
||||||
|
twi_state = TWI_STX;
|
||||||
|
// ready the tx buffer index for iteration
|
||||||
|
twi_txBufferIndex = 0;
|
||||||
|
// set tx buffer length to be zero, to verify if user changes it
|
||||||
|
twi_txBufferLength = 0;
|
||||||
|
// request for txBuffer to be filled and length to be set
|
||||||
|
// note: user must call twi_transmit(bytes, length) to do this
|
||||||
|
twi_onSlaveTransmit();
|
||||||
|
// if they didn't change buffer & length, initialize it
|
||||||
|
if(0 == twi_txBufferLength){
|
||||||
|
twi_txBufferLength = 1;
|
||||||
|
twi_txBuffer[0] = 0x00;
|
||||||
|
}
|
||||||
|
// transmit first byte from buffer, fall
|
||||||
|
case TW_ST_DATA_ACK: // byte sent, ack returned
|
||||||
|
// copy data to output register
|
||||||
|
TWDR = twi_txBuffer[twi_txBufferIndex++];
|
||||||
|
// if there is more to send, ack, otherwise nack
|
||||||
|
if(twi_txBufferIndex < twi_txBufferLength){
|
||||||
|
twi_reply(1);
|
||||||
|
}else{
|
||||||
|
twi_reply(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TW_ST_DATA_NACK: // received nack, we are done
|
||||||
|
case TW_ST_LAST_DATA: // received ack, but we are done already!
|
||||||
|
// ack future responses
|
||||||
|
twi_reply(1);
|
||||||
|
// leave slave receiver state
|
||||||
|
twi_state = TWI_READY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// All
|
||||||
|
case TW_NO_INFO: // no state information
|
||||||
|
break;
|
||||||
|
case TW_BUS_ERROR: // bus error, illegal stop/start
|
||||||
|
twi_error = TW_BUS_ERROR;
|
||||||
|
twi_stop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
55
Wire/utility/twi.h
Normal file
55
Wire/utility/twi.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
twi.h - TWI/I2C library for Wiring & Arduino
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. 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 twi_h
|
||||||
|
#define twi_h
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
//#define ATMEGA8
|
||||||
|
|
||||||
|
#ifndef TWI_FREQ
|
||||||
|
#define TWI_FREQ 100000L
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TWI_BUFFER_LENGTH
|
||||||
|
#define TWI_BUFFER_LENGTH 32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TWI_READY 0
|
||||||
|
#define TWI_MRX 1
|
||||||
|
#define TWI_MTX 2
|
||||||
|
#define TWI_SRX 3
|
||||||
|
#define TWI_STX 4
|
||||||
|
|
||||||
|
void twi_init(void);
|
||||||
|
void twi_disable(void);
|
||||||
|
void twi_setAddress(uint8_t);
|
||||||
|
void twi_setFrequency(uint32_t);
|
||||||
|
uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
|
||||||
|
uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);
|
||||||
|
uint8_t twi_transmit(const uint8_t*, uint8_t);
|
||||||
|
void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) );
|
||||||
|
void twi_attachSlaveTxEvent( void (*)(void) );
|
||||||
|
void twi_reply(uint8_t);
|
||||||
|
void twi_stop(void);
|
||||||
|
void twi_releaseBus(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -10,7 +10,7 @@
|
|||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
#include <Streaming.h>
|
#include <Streaming.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WiFiUDP.h>
|
#include <WiFiUdp.h>
|
||||||
#include <Metro.h>
|
#include <Metro.h>
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#include "hmi.h"
|
#include "hmi.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user