aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Sanson <jamie.sanson@outlook.com>2016-05-13 11:55:34 +1200
committerJamie Sanson <jamie.sanson@outlook.com>2016-05-13 11:55:34 +1200
commitf308e19e263f20709ecca6e82e03a8732ce71d5f (patch)
tree232df242ef0171e343fa54f46764c6f961d5dfcf
parent3c745692637ac054e41f2bdaa11097711eced417 (diff)
downloadmetis-1-onboard-f308e19e263f20709ecca6e82e03a8732ce71d5f.tar.gz
metis-1-onboard-f308e19e263f20709ecca6e82e03a8732ce71d5f.tar.bz2
metis-1-onboard-f308e19e263f20709ecca6e82e03a8732ce71d5f.zip
Add basic microSD logging capability
-rw-r--r--test_flight_basic_logging/test_flight_basic_logging.ino28
1 files changed, 27 insertions, 1 deletions
diff --git a/test_flight_basic_logging/test_flight_basic_logging.ino b/test_flight_basic_logging/test_flight_basic_logging.ino
index 9056804..2c6d0f5 100644
--- a/test_flight_basic_logging/test_flight_basic_logging.ino
+++ b/test_flight_basic_logging/test_flight_basic_logging.ino
@@ -9,6 +9,11 @@
- 9-Axis motion sensor MPU9250 Shield
* Components Outputted to:
- BOB-00544 microSD card SPI breakout
+ * SD card attached to SPI bus as follows:
+ ** MOSI - pin TBD
+ ** MISO - pin TBD
+ ** CLK - pin TBD
+ ** CS - pin TBD
Created 13 May 2016
@@ -19,10 +24,31 @@
*/
+#include <SPI.h>
+#include <SD.h>
+
+const int chipSelect = 0; // Update this with chip select
+const String fileName = "flight_log.txt";
+
void setup() {
-
+ // see if the card is present and can be initialized
+ if (!SD.begin(chipSelect)) {
+ // don't do anything more
+ return;
+ }
}
void loop() {
+
+ // Read sensors and build log string here
+
+ File dataFile = SD.open(fileName, FILE_WRITE);
+
+ if (dataFile) { // Check to see if file is available
+ // Add formatted data here
+ dataFile.print("");
+ // Finalise file write
+ dataFile.close();
+ }
}