diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..80b58c1
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "clickmodules"]
+ path = clickmodules
+ url = https://github.com/Avnet/clickmodules.git
diff --git a/AvnetStarterKitReferenceDesign.sln b/AvnetStarterKitReferenceDesign.sln
index 9873089..57cb4fa 100644
--- a/AvnetStarterKitReferenceDesign.sln
+++ b/AvnetStarterKitReferenceDesign.sln
@@ -1,9 +1,14 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.28307.572
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29306.81
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AvnetStarterKitReferenceDesign", "AvnetStarterKitReferenceDesign\AvnetStarterKitReferenceDesign.vcxproj", "{1EC4AAF4-4A6F-46C8-B538-4F4B9DA1238B}"
+ ProjectSection(ProjectDependencies) = postProject
+ {8A4B3C2D-3514-4F81-8E6A-A869DE31EC07} = {8A4B3C2D-3514-4F81-8E6A-A869DE31EC07}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ClickLib", "ClickLib\ClickLib.vcxproj", "{8A4B3C2D-3514-4F81-8E6A-A869DE31EC07}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +20,10 @@ Global
{1EC4AAF4-4A6F-46C8-B538-4F4B9DA1238B}.Debug|ARM.Build.0 = Debug|ARM
{1EC4AAF4-4A6F-46C8-B538-4F4B9DA1238B}.Release|ARM.ActiveCfg = Release|ARM
{1EC4AAF4-4A6F-46C8-B538-4F4B9DA1238B}.Release|ARM.Build.0 = Release|ARM
+ {8A4B3C2D-3514-4F81-8E6A-A869DE31EC07}.Debug|ARM.ActiveCfg = Debug|ARM
+ {8A4B3C2D-3514-4F81-8E6A-A869DE31EC07}.Debug|ARM.Build.0 = Debug|ARM
+ {8A4B3C2D-3514-4F81-8E6A-A869DE31EC07}.Release|ARM.ActiveCfg = Release|ARM
+ {8A4B3C2D-3514-4F81-8E6A-A869DE31EC07}.Release|ARM.Build.0 = Release|ARM
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/AvnetStarterKitReferenceDesign/AvnetStarterKitReferenceDesign.vcxproj b/AvnetStarterKitReferenceDesign/AvnetStarterKitReferenceDesign.vcxproj
index fc47c2d..89ec74b 100644
--- a/AvnetStarterKitReferenceDesign/AvnetStarterKitReferenceDesign.vcxproj
+++ b/AvnetStarterKitReferenceDesign/AvnetStarterKitReferenceDesign.vcxproj
@@ -68,10 +68,12 @@
-Werror=implicit-function-declaration %(AdditionalOptions)
+ ..\clickmodules\RELAY;%(AdditionalIncludeDirectories)
- applibs;pthread;gcc_s;c;azureiot
+ applibs;pthread;gcc_s;c;azureiot;ClickLib
-Wl,--no-undefined -nodefaultlibs %(AdditionalOptions)
+ ..\ClickLib\bin\ARM\Debug;%(AdditionalLibraryDirectories)
\ No newline at end of file
diff --git a/AvnetStarterKitReferenceDesign/app_manifest.json b/AvnetStarterKitReferenceDesign/app_manifest.json
index bae63f1..3732c19 100644
--- a/AvnetStarterKitReferenceDesign/app_manifest.json
+++ b/AvnetStarterKitReferenceDesign/app_manifest.json
@@ -8,7 +8,7 @@
"AllowedConnections": [],
"AllowedTcpServerPorts": [],
"AllowedUdpServerPorts": [],
- "Gpio": [ 0, 4, 5, 8, 9, 10, 12, 13, 34 ],
+ "Gpio": [ 0, 4, 5, 8, 9, 10, 12, 13, 34, 1, 35 ],
"Uart": [],
"I2cMaster": [ "ISU2" ],
"SpiMaster": [],
diff --git a/AvnetStarterKitReferenceDesign/build_options.h b/AvnetStarterKitReferenceDesign/build_options.h
index 2644231..2a5c0f5 100644
--- a/AvnetStarterKitReferenceDesign/build_options.h
+++ b/AvnetStarterKitReferenceDesign/build_options.h
@@ -7,6 +7,9 @@
// If your application is going to connect straight to a IoT Hub, then enable this define.
//#define IOT_HUB_APPLICATION
+// include relay click module
+//#define RELAY_CLICK
+
#if (defined(IOT_CENTRAL_APPLICATION) && defined(IOT_HUB_APPLICATION))
#error "Can not define both IoT Central and IoT Hub Applications at the same time only define one."
#endif
diff --git a/AvnetStarterKitReferenceDesign/main.c b/AvnetStarterKitReferenceDesign/main.c
index c3527ce..4655f46 100644
--- a/AvnetStarterKitReferenceDesign/main.c
+++ b/AvnetStarterKitReferenceDesign/main.c
@@ -64,6 +64,42 @@
#include
#include
+#if (defined(RELAY_CLICK))
+// relay click section
+
+#include "relay.h"
+
+#define MIKROE_PWM MT3620_GPIO1 //click#1=GPIO0; click#2=GPIO1
+#define MIKROE_CS MT3620_GPIO35 //click#1=GPIO34; click#2=GPIO35
+
+static int r1PinFd; //relay #1
+static GPIO_Value_Type relay1Pin;
+static int r2PinFd; //relay #2
+static GPIO_Value_Type relay2Pin;
+
+void init(void)
+{
+ r1PinFd = GPIO_OpenAsOutput(MIKROE_PWM, relay1Pin, GPIO_Value_Low);
+ r2PinFd = GPIO_OpenAsOutput(MIKROE_CS, relay2Pin, GPIO_Value_Low);
+}
+
+void state(RELAY* ptr)
+{
+ if (ptr->relay1_status == 1)
+ GPIO_SetValue(r1PinFd, GPIO_Value_High);
+ else
+ GPIO_SetValue(r1PinFd, GPIO_Value_Low);
+
+ if (ptr->relay2_status == 1)
+ GPIO_SetValue(r2PinFd, GPIO_Value_High);
+ else
+ GPIO_SetValue(r2PinFd, GPIO_Value_Low);
+}
+
+// relay click section
+#endif
+
+
// Provide local access to variables in other files
extern twin_t twinArray[];
extern int twinArraySize;
@@ -492,6 +528,15 @@ int main(int argc, char *argv[])
// Clear the ssid array
memset(ssid, 0, 128);
+#if (defined(RELAY_CLICK))
+ int i;
+ RELAY* rptr;
+
+ rptr = open_relay(state, init);
+ sleep(1);
+ i = 0;
+#endif
+
Log_Debug("Version String: %s\n", argv[1]);
Log_Debug("Avnet Starter Kit Simple Reference Application starting.\n");
if (InitPeripheralsAndHandlers() != 0) {
@@ -500,6 +545,17 @@ int main(int argc, char *argv[])
// Use epoll to wait for events and trigger handlers, until an error or SIGTERM happens
while (!terminationRequired) {
+
+#if (defined(RELAY_CLICK))
+ relaystate(rptr, (i & 1) ? relay1_set : relay1_clr);
+ relaystate(rptr, (i & 2) ? relay2_set : relay2_clr);
+ Log_Debug("(%d) relay2 %s, relay1 %s\n", i,
+ relaystate(rptr, relay2_rd) ? "ON" : "OFF",
+ relaystate(rptr, relay1_rd) ? "ON" : "OFF");
+ sleep(10);
+ ++i;
+#endif
+
if (WaitForEventAndCallHandler(epollFd) != 0) {
terminationRequired = true;
}
@@ -559,6 +615,14 @@ int main(int argc, char *argv[])
#endif
}
+#if (defined(RELAY_CLICK))
+ close_relay(rptr);
+ GPIO_SetValue(r1PinFd, GPIO_Value_Low);
+ GPIO_SetValue(r2PinFd, GPIO_Value_Low);
+ Log_Debug("relay2 OFF, relay1 oFF\nDONE...\n");
+#endif
+
+
ClosePeripheralsAndHandlers();
Log_Debug("Application exiting.\n");
return 0;
diff --git a/ClickLib/ClickLib.vcxproj b/ClickLib/ClickLib.vcxproj
new file mode 100644
index 0000000..28a1502
--- /dev/null
+++ b/ClickLib/ClickLib.vcxproj
@@ -0,0 +1,56 @@
+
+
+
+
+ Debug
+ ARM
+
+
+ Release
+ ARM
+
+
+
+
+
+
+
+
+
+ {8a4b3c2d-3514-4f81-8e6a-a869de31ec07}
+ AzureSphere
+ ClickLib
+ 15.0
+ Linux
+ 1.0
+ Generic
+ {D51BCBC9-82E9-4017-911E-C93873C4EA2B}
+ Device
+ GCC_AzureSphere_1_0
+ $(MSBuildProjectDirectory)\Inc\Public
+ $(MSBuildProjectDirectory)\Inc\Public
+
+
+
+ true
+ 1
+ StaticLibrary
+
+
+ false
+ 1
+ StaticLibrary
+
+
+
+
+
+
+
+
+ -Werror=implicit-function-declaration %(AdditionalOptions)
+
+
+
+
+
\ No newline at end of file
diff --git a/ClickLib/ClickLib.vcxproj.filters b/ClickLib/ClickLib.vcxproj.filters
new file mode 100644
index 0000000..927fda8
--- /dev/null
+++ b/ClickLib/ClickLib.vcxproj.filters
@@ -0,0 +1,27 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+
\ No newline at end of file
diff --git a/clickmodules b/clickmodules
new file mode 160000
index 0000000..083235a
--- /dev/null
+++ b/clickmodules
@@ -0,0 +1 @@
+Subproject commit 083235a4b19db2482bf20cda4b245a73bd0a2600