From 7f2cb27dc8d96113ff52740ab7b70e555956d326 Mon Sep 17 00:00:00 2001 From: Kaloyan Mihaylov <kaloyan.mihaylov@gmail.com> Date: Wed, 9 Sep 2020 10:03:35 +0300 Subject: [PATCH 1/6] Add CS5460 submodule --- .gitmodules | 5 +++++ Sming/Libraries/CS5460/CS5460 | 1 + 2 files changed, 6 insertions(+) create mode 160000 Sming/Libraries/CS5460/CS5460 diff --git a/.gitmodules b/.gitmodules index de26ab39fb..1301896127 100644 --- a/.gitmodules +++ b/.gitmodules @@ -149,3 +149,8 @@ path = Sming/Libraries/modbusino/modbusino url = https://github.com/kmihaylov/modbusino.git ignore = dirty +[submodule "Libraries.CS5460"] + path = Sming/Libraries/CS5460/CS5460 + url = https://github.com/xxzl0130/CS5460.git + ignore = dirty + diff --git a/Sming/Libraries/CS5460/CS5460 b/Sming/Libraries/CS5460/CS5460 new file mode 160000 index 0000000000..9a3e564287 --- /dev/null +++ b/Sming/Libraries/CS5460/CS5460 @@ -0,0 +1 @@ +Subproject commit 9a3e56428737f4cd21b1c8da79def35bcf568d70 From a00367482cd9312222f6c542abd92bccb34f1ec0 Mon Sep 17 00:00:00 2001 From: Kaloyan Mihaylov <kaloyan.mihaylov@gmail.com> Date: Wed, 9 Sep 2020 10:18:57 +0300 Subject: [PATCH 2/6] Add CS5460 patch file --- Sming/Libraries/CS5460/CS5460.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Sming/Libraries/CS5460/CS5460.patch diff --git a/Sming/Libraries/CS5460/CS5460.patch b/Sming/Libraries/CS5460/CS5460.patch new file mode 100644 index 0000000000..153c3b447e --- /dev/null +++ b/Sming/Libraries/CS5460/CS5460.patch @@ -0,0 +1,14 @@ +diff --git a/CS5460.h b/CS5460.h +index 0fbbb5b..fe7ff1d 100644 +--- a/CS5460.h ++++ b/CS5460.h +@@ -1,7 +1,8 @@ + #ifndef __CS5460_H__ + #define __CS5460_H__ + +-#include <arduino.h> ++//#include <arduino.h> ++#include <SmingCore/SmingCore.h> + #include <stdint.h> + #include <SPI.h> + From f2e3e4f2f7eeb6ea58957b0578b1625a51e12243 Mon Sep 17 00:00:00 2001 From: Kaloyan Mihaylov <kaloyan.mihaylov@gmail.com> Date: Fri, 11 Sep 2020 11:52:59 +0300 Subject: [PATCH 3/6] Fix CS5460 patch file --- Sming/Libraries/CS5460/CS5460.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sming/Libraries/CS5460/CS5460.patch b/Sming/Libraries/CS5460/CS5460.patch index 153c3b447e..437962424c 100644 --- a/Sming/Libraries/CS5460/CS5460.patch +++ b/Sming/Libraries/CS5460/CS5460.patch @@ -8,7 +8,7 @@ index 0fbbb5b..fe7ff1d 100644 -#include <arduino.h> +//#include <arduino.h> -+#include <SmingCore/SmingCore.h> ++#include <SmingCore.h> #include <stdint.h> #include <SPI.h> From bdd27f0e60ade30184584a2f29ee070ef26e2ca8 Mon Sep 17 00:00:00 2001 From: Kaloyan Mihaylov <kaloyan.mihaylov@gmail.com> Date: Fri, 11 Sep 2020 11:53:32 +0300 Subject: [PATCH 4/6] Add CS5460 component.mk file with default MISO value --- Sming/Libraries/CS5460/component.mk | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Sming/Libraries/CS5460/component.mk diff --git a/Sming/Libraries/CS5460/component.mk b/Sming/Libraries/CS5460/component.mk new file mode 100644 index 0000000000..e01261a7e6 --- /dev/null +++ b/Sming/Libraries/CS5460/component.mk @@ -0,0 +1,7 @@ +COMPONENT_SUBMODULES := CS5460 +COMPONENT_SRCDIRS := CS5460 +COMPONENT_INCDIRS := CS5460 + +COMPONENT_VARS += MISO +MISO ?= 12 +COMPONENT_CXXFLAGS += -DMISO=$(MISO) From 0e7f647b361b05fe4a8c8c1c72357cf4699fe64e Mon Sep 17 00:00:00 2001 From: Kaloyan Mihaylov <kaloyan.mihaylov@gmail.com> Date: Fri, 11 Sep 2020 12:30:40 +0300 Subject: [PATCH 5/6] Add CS5460 sample --- .../Libraries/CS5460/samples/generic/Makefile | 9 ++++++ .../CS5460/samples/generic/README.rst | 14 +++++++++ .../Libraries/CS5460/samples/generic/app/.cs | 0 .../samples/generic/app/application.cpp | 29 +++++++++++++++++++ .../CS5460/samples/generic/component.mk | 2 ++ 5 files changed, 54 insertions(+) create mode 100644 Sming/Libraries/CS5460/samples/generic/Makefile create mode 100644 Sming/Libraries/CS5460/samples/generic/README.rst create mode 100644 Sming/Libraries/CS5460/samples/generic/app/.cs create mode 100644 Sming/Libraries/CS5460/samples/generic/app/application.cpp create mode 100644 Sming/Libraries/CS5460/samples/generic/component.mk diff --git a/Sming/Libraries/CS5460/samples/generic/Makefile b/Sming/Libraries/CS5460/samples/generic/Makefile new file mode 100644 index 0000000000..ff51b6c3a7 --- /dev/null +++ b/Sming/Libraries/CS5460/samples/generic/Makefile @@ -0,0 +1,9 @@ +##################################################################### +#### Please don't change this file. Use component.mk instead #### +##################################################################### + +ifndef SMING_HOME +$(error SMING_HOME is not set: please configure it as an environment variable) +endif + +include $(SMING_HOME)/project.mk diff --git a/Sming/Libraries/CS5460/samples/generic/README.rst b/Sming/Libraries/CS5460/samples/generic/README.rst new file mode 100644 index 0000000000..9c19108ed1 --- /dev/null +++ b/Sming/Libraries/CS5460/samples/generic/README.rst @@ -0,0 +1,14 @@ +CS5460 generic sample +===================== + +.. highlight:: bash + +The sample prints the measured RMS voltage each second (with CS5460 voltage and current filters enabled). + +The default MISO pin (12) can be changed through the envvar:`MISO` variable. For example:: + + make MISO=13 + +These variables can be listed with:: + + make list-config diff --git a/Sming/Libraries/CS5460/samples/generic/app/.cs b/Sming/Libraries/CS5460/samples/generic/app/.cs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Sming/Libraries/CS5460/samples/generic/app/application.cpp b/Sming/Libraries/CS5460/samples/generic/app/application.cpp new file mode 100644 index 0000000000..e757668772 --- /dev/null +++ b/Sming/Libraries/CS5460/samples/generic/app/application.cpp @@ -0,0 +1,29 @@ +#include <SmingCore.h> +#include <Debug.h> +#include <CS5460.h> + +CS5460 powerMeter(PIN_NDEFINED, PIN_NDEFINED, PIN_NDEFINED, PIN_NDEFINED); + +Timer printVoltageTimer; + +void printVoltage() +{ + debugf("Measured RMS voltage is: %f", powerMeter.getRMSVoltage()); +} + +void init() +{ + Serial.begin(SERIAL_BAUD_RATE, SERIAL_8N1, + SERIAL_FULL); // 115200 by default, GPIO1,GPIO3, see Serial.swap(), HardwareSerial + Serial.systemDebugOutput(true); + Debug.setDebug(Serial); + + powerMeter.init(); + powerMeter.setCurrentGain(190.84); //0.25 / shunt (0.00131) + powerMeter.setVoltageGain(500); //0.25V (Veff max) * dividerGain + powerMeter.writeRegister(CONFIG_REGISTER, ENABLE_CURRENT_HPF); + powerMeter.writeRegister(CONFIG_REGISTER, ENABLE_VOLTAGE_HPF); + powerMeter.startMultiConvert(); + + printVoltageTimer.initializeMs(1000, printVoltage).start(); +} diff --git a/Sming/Libraries/CS5460/samples/generic/component.mk b/Sming/Libraries/CS5460/samples/generic/component.mk new file mode 100644 index 0000000000..51f1520d50 --- /dev/null +++ b/Sming/Libraries/CS5460/samples/generic/component.mk @@ -0,0 +1,2 @@ +ARDUINO_LIBRARIES := CS5460 +DISABLE_SPIFFS = 1 From 1c85cf36c21e5d41cfe870067c3bfb872b2e643a Mon Sep 17 00:00:00 2001 From: Slavey Karadzhov <slav@attachix.com> Date: Mon, 14 Sep 2020 11:49:13 +0200 Subject: [PATCH 6/6] Simplified Arduino include change. --- Sming/Libraries/CS5460/CS5460.patch | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Sming/Libraries/CS5460/CS5460.patch b/Sming/Libraries/CS5460/CS5460.patch index 437962424c..a8c2adc3a0 100644 --- a/Sming/Libraries/CS5460/CS5460.patch +++ b/Sming/Libraries/CS5460/CS5460.patch @@ -2,13 +2,12 @@ diff --git a/CS5460.h b/CS5460.h index 0fbbb5b..fe7ff1d 100644 --- a/CS5460.h +++ b/CS5460.h -@@ -1,7 +1,8 @@ +@@ -1,7 +1,7 @@ #ifndef __CS5460_H__ #define __CS5460_H__ -#include <arduino.h> -+//#include <arduino.h> -+#include <SmingCore.h> ++#include <Arduino.h> #include <stdint.h> #include <SPI.h>