-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add CS5460 submodule * Add CS5460 component.mk file with default MISO value * Add CS5460 sample * Simplified Arduino include change.
- Loading branch information
Showing
9 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/CS5460.h b/CS5460.h | ||
index 0fbbb5b..fe7ff1d 100644 | ||
--- a/CS5460.h | ||
+++ b/CS5460.h | ||
@@ -1,7 +1,7 @@ | ||
#ifndef __CS5460_H__ | ||
#define __CS5460_H__ | ||
|
||
-#include <arduino.h> | ||
+#include <Arduino.h> | ||
#include <stdint.h> | ||
#include <SPI.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
COMPONENT_SUBMODULES := CS5460 | ||
COMPONENT_SRCDIRS := CS5460 | ||
COMPONENT_INCDIRS := CS5460 | ||
|
||
COMPONENT_VARS += MISO | ||
MISO ?= 12 | ||
COMPONENT_CXXFLAGS += -DMISO=$(MISO) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Empty file.
29 changes: 29 additions & 0 deletions
29
Sming/Libraries/CS5460/samples/generic/app/application.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ARDUINO_LIBRARIES := CS5460 | ||
DISABLE_SPIFFS = 1 |