From 14bba8c63d3ed6faafc505fce201a43a244db168 Mon Sep 17 00:00:00 2001 From: biomurph Date: Thu, 2 Mar 2017 10:55:22 -0500 Subject: [PATCH] Firmware update v1.1.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made changes to the SD card code so that it doesn’t use the virtual EEPROM --- .../Definitions_Ganglion.h | 1 - .../OpenBCI_Ganglion_Library.cpp | 6 +-- .../DefaultGanglion/DefaultGanglion.ino | 29 ++--------- .../GanglionWithSD.ino} | 23 +++++++-- .../SD_Card_Stuff.ino | 50 ++++++------------- 5 files changed, 39 insertions(+), 70 deletions(-) rename OpenBCI_Ganglion_Library/examples/{GanglionNoSD/GanglionNoSD.ino => GanglionWithSD/GanglionWithSD.ino} (61%) rename OpenBCI_Ganglion_Library/examples/{DefaultGanglion => GanglionWithSD}/SD_Card_Stuff.ino (91%) diff --git a/OpenBCI_Ganglion_Library/Definitions_Ganglion.h b/OpenBCI_Ganglion_Library/Definitions_Ganglion.h index 3610e4c..aa0b66d 100644 --- a/OpenBCI_Ganglion_Library/Definitions_Ganglion.h +++ b/OpenBCI_Ganglion_Library/Definitions_Ganglion.h @@ -195,5 +195,4 @@ */ #define SD_SS 17 -#define MAGIC_NUMBER 0xDEADBEEF #endif diff --git a/OpenBCI_Ganglion_Library/OpenBCI_Ganglion_Library.cpp b/OpenBCI_Ganglion_Library/OpenBCI_Ganglion_Library.cpp index ccf254f..3775aae 100644 --- a/OpenBCI_Ganglion_Library/OpenBCI_Ganglion_Library.cpp +++ b/OpenBCI_Ganglion_Library/OpenBCI_Ganglion_Library.cpp @@ -67,7 +67,7 @@ OpenBCI_Ganglion::OpenBCI_Ganglion(){ SimbleeBLE.manufacturerName = "openbci.com"; SimbleeBLE.modelNumber = "Ganglion"; SimbleeBLE.hardwareRevision = "1.0.0"; - SimbleeBLE.softwareRevision = "1.0.0"; + SimbleeBLE.softwareRevision = "1.1.1"; } void OpenBCI_Ganglion::blinkLED() { @@ -87,7 +87,7 @@ OpenBCI_Ganglion::OpenBCI_Ganglion(){ config_LIS2DH(); config_MCP3912(g, s); updateDAC(DACmidline); // place DAC into V/2 position - loadString("OpenBCI Ganglion v1.0.0\n", 24, false); + loadString("OpenBCI Ganglion v",18,false); loadString((char*)SimbleeBLE.softwareRevision, 5, true); for (int i = 2; i <= advdata[0]; i++) { loadChar(advdata[i], false); } @@ -1124,7 +1124,7 @@ OpenBCI_Ganglion::OpenBCI_Ganglion(){ startRunning(); } break; - case ENABLE_OTA: + case ENABLE_OTA: // '>' requestForOTAenable = true; if(!BLEconnected){ clearForOTA = true; } break; diff --git a/OpenBCI_Ganglion_Library/examples/DefaultGanglion/DefaultGanglion.ino b/OpenBCI_Ganglion_Library/examples/DefaultGanglion/DefaultGanglion.ino index b8d143b..359154b 100644 --- a/OpenBCI_Ganglion_Library/examples/DefaultGanglion/DefaultGanglion.ino +++ b/OpenBCI_Ganglion_Library/examples/DefaultGanglion/DefaultGanglion.ino @@ -4,7 +4,7 @@ Uesd to test the basic functionality of the Ganglion Board Targets a Simblee. LIS2DH, MCP3912, AD5621 on board - Made by Joel Murphy, Leif Percifield, and AJ Keller for OpenBCI, Inc. 2016 + Made by Joel Murphy, Leif Percifield, AJ Keller, and Conor Russomanno for OpenBCI, Inc. 2016 MUST CHANGE THE SPI PINS IN THE variants.h FILE @@ -16,28 +16,12 @@ */ #include -#include - - - - -struct data_t -{ // magicNumber reminds Ganglion that the last file name is in flash - int magicNumber; - int fileOnes; - int fileTens; -}; -// Storing file name enumerator in Flash [secret EEPROM] -struct data_t *flash = (data_t*)ADDRESS_OF_PAGE(MY_FLASH_PAGE); - -boolean SDfileOpen = false; // Set true by SD_Card_Stuff.ino on successful file open void setup() { ganglion.initialize(); attachPinInterrupt(MCP_DRDY, MCP_ISR, LOW); - // look for magicNumber to see if there is a file enumerator stored - if (flash->magicNumber != MAGIC_NUMBER){ flashSave(0, 0); } + } @@ -46,18 +30,11 @@ void loop() { if(ganglion.MCP_dataReady){ ganglion.processData(); - - if(SDfileOpen) { // Verify the SD file is open - // Write to the SD card - writeDataToSDcard(ganglion.sampleCounter); - } } ganglion.blinkLED(); - if(ganglion.eventSerial()){ - sdProcessChar(ganglion.inChar); // check for an SD related command - } + ganglion.eventSerial(); if(ganglion.testingImpedance){ ganglion.testImpedance(); diff --git a/OpenBCI_Ganglion_Library/examples/GanglionNoSD/GanglionNoSD.ino b/OpenBCI_Ganglion_Library/examples/GanglionWithSD/GanglionWithSD.ino similarity index 61% rename from OpenBCI_Ganglion_Library/examples/GanglionNoSD/GanglionNoSD.ino rename to OpenBCI_Ganglion_Library/examples/GanglionWithSD/GanglionWithSD.ino index 359154b..ba139a2 100644 --- a/OpenBCI_Ganglion_Library/examples/GanglionNoSD/GanglionNoSD.ino +++ b/OpenBCI_Ganglion_Library/examples/GanglionWithSD/GanglionWithSD.ino @@ -4,10 +4,10 @@ Uesd to test the basic functionality of the Ganglion Board Targets a Simblee. LIS2DH, MCP3912, AD5621 on board - Made by Joel Murphy, Leif Percifield, AJ Keller, and Conor Russomanno for OpenBCI, Inc. 2016 + Made by Joel Murphy, Leif Percifield, and AJ Keller for OpenBCI, Inc. 2016 - MUST CHANGE THE SPI PINS IN THE variants.h FILE + MUST CHANGE THE SPI PINS IN THE variants.h FILE Lines 88-92 #define SPI_INTERFACE NRF_SPI0 #define PIN_SPI_SS (26u) //(6u) #define PIN_SPI_MOSI (18u) //(5u) @@ -16,25 +16,40 @@ */ #include +#include + + +boolean SDfileOpen = false; // Set true by SD_Card_Stuff.ino on successful file open + +unsigned long thisTime; +unsigned long thatTime; void setup() { ganglion.initialize(); attachPinInterrupt(MCP_DRDY, MCP_ISR, LOW); - } void loop() { if(ganglion.MCP_dataReady){ + ganglion.processData(); + + + if(SDfileOpen) { // Verify the SD file is open + // Write to the SD card + writeDataToSDcard(ganglion.sampleCounter); + } } ganglion.blinkLED(); - ganglion.eventSerial(); + if(ganglion.eventSerial()){ + sdProcessChar(ganglion.inChar); // check for an SD related command + } if(ganglion.testingImpedance){ ganglion.testImpedance(); diff --git a/OpenBCI_Ganglion_Library/examples/DefaultGanglion/SD_Card_Stuff.ino b/OpenBCI_Ganglion_Library/examples/GanglionWithSD/SD_Card_Stuff.ino similarity index 91% rename from OpenBCI_Ganglion_Library/examples/DefaultGanglion/SD_Card_Stuff.ino rename to OpenBCI_Ganglion_Library/examples/GanglionWithSD/SD_Card_Stuff.ino index ef4ad55..874cff0 100644 --- a/OpenBCI_Ganglion_Library/examples/DefaultGanglion/SD_Card_Stuff.ino +++ b/OpenBCI_Ganglion_Library/examples/GanglionWithSD/SD_Card_Stuff.ino @@ -11,21 +11,6 @@ #define OVER_DIM 20 // make room for up to 20 write-time overruns - - - -void flashSave(int fOnes, int fTens){ - flashPageErase(MY_FLASH_PAGE); - - struct data_t number; - number.magicNumber = MAGIC_NUMBER; - number.fileOnes = fOnes; - number.fileTens = fTens; - - flashWriteBlock(flash, &number, sizeof(number)); -} - - char fileSize = '0'; // SD file size indicator int blockCounter = 0; @@ -52,8 +37,8 @@ uint32_t maxWriteTime; // keep track of longest write time uint32_t minWriteTime; // and shortest write time uint32_t t; // used to measure total file write time -int fileTens, fileOnes; // enumerate succesive files on card and store number in EEPROM -char currentFileName[] = "OBCI_00.csv"; // file name will enumerate in hex 00 - FF +int fileHundreds, fileTens, fileOnes; // enumerate succesive files on card and store number in EEPROM +char currentFileName[] = "OBCI_000.csv"; // file name will enumerate 000 to 999 char elapsedTime[] = {"\n%Total time mS:\n"}; // 17 char minTime[] = { "%min Write time uS:\n"}; // 20 char maxTime[] = { "%max Write time uS:\n"}; // 20 @@ -153,14 +138,14 @@ boolean setupSDcard(char limit){ default: if(!ganglion.is_running) { ganglion.loadString("invalid BLOCK count",19,true); - // ganglion.sendEOT(); // Write end of transmission because we exit here } return fileIsOpen; + break; } - incrementFileCounter(); openvol = root.openRoot(volume); - // Serial.print("openvol = "); Serial.println(openvol); + int numFiles = root.ls(0x00); + incrementFileCounter(numFiles+1); openfile.remove(root, currentFileName); // if the file is over-writing, let it! if (!openfile.createContiguous(root, currentFileName, BLOCK_COUNT*512UL)) { if(!ganglion.is_running) { @@ -203,7 +188,7 @@ boolean setupSDcard(char limit){ if(fileIsOpen == true){ // send corresponding file name to controlling program ganglion.writingToSD = true; ganglion.loadString("Writing to file: ",17,false); - for(int i=0; i<11; i++){ + for(int i=0; i<12; i++){ ganglion.loadChar(currentFileName[i],false); } ganglion.loadNewLine(); @@ -315,21 +300,14 @@ void writeCache(){ } -void incrementFileCounter(){ - fileTens = flash->fileTens; - fileOnes = flash->fileOnes; - fileOnes++; // increment the file name - if (fileOnes + '0' == ':'){fileOnes = 'A'-'0';} - if (fileOnes + '0' > 'F'){ - fileOnes = 0; - fileTens++; - if(fileTens + '0' == ':'){fileTens = 'A'-'0';} - if(fileTens + '0' > 'F'){fileTens = 0;fileOnes = 1;} - } - flashSave(fileOnes, fileTens); - currentFileName[5] = fileTens + '0'; - currentFileName[6] = fileOnes + '0'; -} + void incrementFileCounter(int numFiles){ + fileOnes = numFiles%10; + fileTens = (numFiles/10)%10; + fileHundreds = (numFiles/100)%10; + currentFileName[5] = fileHundreds + '0'; + currentFileName[6] = fileTens + '0'; + currentFileName[7] = fileOnes + '0'; + } void stampSD(boolean state){ unsigned long time = millis();