Skip to content

Commit

Permalink
Firmware update v1.1.1
Browse files Browse the repository at this point in the history
Made changes to the SD card code so that it doesn’t use the virtual
EEPROM
  • Loading branch information
biomurph committed Mar 2, 2017
1 parent 9c8e661 commit 14bba8c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 70 deletions.
1 change: 0 additions & 1 deletion OpenBCI_Ganglion_Library/Definitions_Ganglion.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,4 @@
*/

#define SD_SS 17
#define MAGIC_NUMBER 0xDEADBEEF
#endif
6 changes: 3 additions & 3 deletions OpenBCI_Ganglion_Library/OpenBCI_Ganglion_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}
Expand Down Expand Up @@ -1124,7 +1124,7 @@ OpenBCI_Ganglion::OpenBCI_Ganglion(){
startRunning();
}
break;
case ENABLE_OTA:
case ENABLE_OTA: // '>'
requestForOTAenable = true;
if(!BLEconnected){ clearForOTA = true; }
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,28 +16,12 @@
*/

#include <OpenBCI_Ganglion_Library.h>
#include <OBCI_Ganglion_SD.h>




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); }


}

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -16,25 +16,40 @@
*/

#include <OpenBCI_Ganglion_Library.h>
#include <OBCI_Ganglion_SD.h>


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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 14bba8c

Please sign in to comment.