-
-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CS5460 Arduino library #2106
Merged
Merged
CS5460 Arduino library #2106
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7f2cb27
Add CS5460 submodule
kmihaylov a003674
Add CS5460 patch file
kmihaylov f2e3e4f
Fix CS5460 patch file
kmihaylov bdd27f0
Add CS5460 component.mk file with default MISO value
kmihaylov 0e7f647
Add CS5460 sample
kmihaylov 1c85cf3
Simplified Arduino include change.
slav-at-attachix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try to replace
<arduino.h>
with<Arduino.h>
and see if the library compiles and works?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating it!