OpenLog Qwiic - How to Close Communication to Allow Interrupts

Hi all,

I am using the FlexiTimer2.h library to collect analog data and would like to save the data on a micro SD that is connected to the RedBoard via a Qwiic connector. When I used interrupts in my past, I usually turned off the interrupts, started communication with the sd card, wrote the data, closed communication with the sd card, and turned on interrupts again.

Now I have the problem, that I cannot find a call in the OpenLog library that allows me to close the communication.

https://github.com/sparkfun/SparkFun_Qw … no_Library

It seems to just have a begin() function.

Here is the code that I am using, maybe someone has some idea, how else I could write data to the micro SD with this code?

#include <compat/deprecated.h>
#include <FlexiTimer2.h>
#define SAMPFREQ 20                      // ADC sampling rate 256
#define TIMER2VAL (1000/(SAMPFREQ))       // Set 256Hz sampling frequency                    
volatile unsigned char CurrentCh=0;         //Current channel being sampled.
volatile unsigned int ADC_Value = 0;    //ADC current value

//*** added these lines for logging
#include <Wire.h>
#include "SparkFun_Qwiic_OpenLog_Arduino_Library.h"
OpenLog myLog; //Create instance
char filename[11] = "ECGdata.txt";
//***

void setup() {

noInterrupts();  // Disable all interrupts before initialization

FlexiTimer2::set(TIMER2VAL, Timer2_Overflow_ISR);
FlexiTimer2::start();

// Serial Port
Serial.begin(57600);
//*** added these lines for logging

  //Wire.begin();
  //myLog.begin(); //Open connection to OpenLog (no pun intended)
  //myLog.syncFile();
  //myLog.append(filename); // change to your own file nameexample
  
 // ***
interrupts();  // Enable all interrupts after initialization has been completed
}

void Timer2_Overflow_ISR()
{
        ADC_Value = analogRead(CurrentCh);
        //Serial.print("D!");    //this is packet header for my application
        Serial.print(millis());
        Serial.print(", ");
        Serial.println(ADC_Value);
}

void loop() {
__asm__ __volatile__ ("sleep");
}

I would like to save the data that right now is sent to the serial monitor.

Thanks for the help.

Cheers,

Patrick