-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSDuser.cpp
More file actions
54 lines (48 loc) · 1.29 KB
/
Copy pathSDuser.cpp
File metadata and controls
54 lines (48 loc) · 1.29 KB
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
#include <SDuser.h>
#define SD_CS 9
#define SD_SCK 15
#define SD_MISO 17
#define SD_MOSI 7
// #define SD_CS 12
// #define SD_SCK 22
// #define SD_MISO 21
// #define SD_MOSI 32
void initSD(void)
{
pinMode(SD_CS, OUTPUT);
digitalWrite(SD_CS, HIGH);
SPI.begin(SD_SCK, SD_MISO, SD_MOSI);
SPI.setFrequency(1000000);
if(!SD.begin(SD_CS, SPI))Serial.println("Card Mount Failed");
else Serial.println("Card Mount Success");
uint8_t cardType = SD.cardType();
if(cardType == CARD_NONE)Serial.println("No SD card attached");
else
{
Serial.print("SD Card Type: ");
if(cardType == CARD_MMC)Serial.println("MMC");
else if(cardType == CARD_SD)Serial.println("SDSC");
else if(cardType == CARD_SDHC)Serial.println("SDHC");
else Serial.println("UNKNOWN");
}
// lv_fs_fatfs_init();
}
void lv_fs_test(void)
{
lv_fs_file_t f;
lv_fs_res_t res;
res = lv_fs_open(&f, "S:test/file.txt", LV_FS_MODE_RD);
if(res != LV_FS_RES_OK)
{
Serial.println("Open fail");
}
else
{
Serial.println("Open OK");
uint32_t read_num;
uint8_t buf[8];
res = lv_fs_read(&f, buf, 8, &read_num);
Serial.printf("read:%s",buf);
lv_fs_close(&f);
}
}