-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSD.cpp
More file actions
41 lines (32 loc) · 684 Bytes
/
SD.cpp
File metadata and controls
41 lines (32 loc) · 684 Bytes
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
#include <fstream>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include "SD.h"
using namespace std;
FILE *fp;
void SD_read(uint32_t bytesToRead, uint8_t* buffer) {
if (fp == NULL) {
printf("FILE ERROR\n");
return;
}
for(int i = 0; i < bytesToRead; i++) {
fread(buffer + i, 1, 1, fp);
}
}
char SD_readNextChar() {
char c[1];
fread(c, 1, 1, fp);
return c[0];
}
void SD_openFile(char* filename) {
fp = fopen(filename, "rb");
if(fp == NULL) {
printf("Error: Cannot open file %s\n", filename);
while(1);
}
}
void SD_closeFile() {
if(fp != NULL) fclose(fp);
}
void SD_startSDCard() {}