#include <SD.h>
#include <iostream>
#include <string>
using namespace std;
#include "support.h"
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
// Define SD card connection
#define SD_MOSI_PIN 23
#define SD_MISO_PIN 19
#define SD_SCLK_PIN 18
#define SD_CS_PIN 5
void load_SD_card(){
// load SD card
if (!SD.begin(SD_CS_PIN)) {
Serial.println("Card initialization failed!");
while (true);
}
}
void test(void *p){
File f = *((File *)p);
char c = f.read();
c = f.read();
cout << c << ";" << (int)c << endl;
vTaskDelete(NULL); // 任務執行完畢後刪除自身
}
void setup(){
Serial.begin(115200);
load_SD_card();
File textFile = SD.open("/test.txt", FILE_READ);
// xTaskCreatePinnedToCore(test, "test", 8192, &textFile, 1, NULL, 1);
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
cout << (int)textFile.read() << endl;
}
void loop(){
delay(5000);
}