   pinMode(WIFI_SS,OUTPUT); digitalWrite(WIFI_SS,HIGH);
 
   spi.begin();
-  spi.setSpeed(20000000);  // use 4MHz for ADS and LIS3DH
+  spi.setSpeed(8000000);  // use 4MHz for ADS and LIS3DH
   spi.setMode(DSPI_MODE0);  // default to SD card mode!
 
   Serial0.begin(115200);

        Serial0.println("starting stream");
        break;
      case 's':
        streaming = true;
        Serial0.println("stopping stream");
        break;
      case '0':
        digitalWrite(WIFI_SS,LOW);
        Serial0.println("forced pin 13 to low");

void flushbufToSpi() {
  uint8_t i = 0;
  uint8_t len = packetSize;
  if (wifi) digitalWrite(WIFI_SS,LOW);
  spi.transfer(0x02);
  spi.transfer(0x00);
  while(i < packetSize) {
      spi.transfer('a');
      i++;
  }
  if (wifi) digitalWrite(WIFI_SS,HIGH);
}
