-
Notifications
You must be signed in to change notification settings - Fork 5
/
SDCard.cpp
56 lines (47 loc) · 1.02 KB
/
SDCard.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "SDCard.h"
SdFat sd;
File file;
SoftSpiDriver<SOFT_MISO_PIN, SOFT_MOSI_PIN, SOFT_SCK_PIN> softSpi;
void activateSDBus()
{
digitalWrite(SD_CS_PIN, 1);
pinMode(SD_CS_PIN, OUTPUT);
digitalWrite(SOFT_MOSI_PIN, 1);
pinMode(SOFT_MOSI_PIN, OUTPUT);
digitalWrite(SOFT_SCK_PIN, 1);
pinMode(SOFT_SCK_PIN, OUTPUT);
pinMode(SOFT_MISO_PIN, INPUT_PULLUP);
}
void deactivateSDBus()
{
pinMode(SD_CS_PIN, INPUT_PULLUP);
pinMode(SOFT_MOSI_PIN, INPUT_PULLUP);
pinMode(SOFT_SCK_PIN, INPUT_PULLUP);
pinMode(SOFT_MISO_PIN, INPUT_PULLUP);
}
void setupSDBus()
{
deactivateSDBus();
}
#if 0
bool initSDCard()
{
activateSDBus();
if (!sd.begin(SD_CONFIG)) {
sd.initErrorPrint();
Serial.print("[ERROR] Can't access SD Card: ");
Serial.print(sd.sdErrorCode()); // errorData()
Serial.print(" : ");
Serial.println(sd.sdErrorData()); // errorData()
sd.errorPrint("SD Card error:");
Serial.flush();
return false;
}
return true;
}
#else
bool initSDCard()
{
return sd.begin(SD_CONFIG);
}
#endif