#include "FS.h"
#include "SD.h"
#include "SD_MMC.h"
void WriteFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
//unsigned long start_time = millis();
Serial.printf("write [%s]...\n", path);
File file = fs.open(path, FILE_WRITE);
if (!file) {
Serial.println("Failed to open file for writing");
return;
}
if (!file.write(buf, len)) {
Serial.println("Write failed");
return;
}
file.flush();
file.close();
Serial.printf("Write [%s] Complete", path);
}
void ReadFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
Serial.printf("read [%s]...\n", path);
File file = fs.open(path);
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
if (!file.read(buf, len)) {
Serial.println("Read failed");
return;
}
file.close();
Serial.printf("Read [%s] Complete: %s", path, buf);
}
void testIO(fs::FS &fs)
{
char buf[] = "hello world";
WriteFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
ReadFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("请插入内存卡");
delay(8000);
/* SD_MMC 4-bit Mode */
if (!SD_MMC.begin()) {
Serial.println("Card Mount Failed");
return;
}
testIO(SD_MMC);
SD_MMC.end(); // 取消SD挂载
}
void loop() {
}
#include "FS.h"
#include "SD.h"
#include "SD_MMC.h"
void WriteFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
//unsigned long start_time = millis();
Serial.printf("write [%s]...\n", path);
File file = fs.open(path, FILE_WRITE);
if (!file) {
Serial.println("Failed to open file for writing");
return;
}
if (!file.write(buf, len)) {
Serial.println("Write failed");
return;
}
file.flush();
file.close();
Serial.printf("Write [%s] Complete", path);
}
void ReadFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
Serial.printf("read [%s]...\n", path);
File file = fs.open(path);
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
if (!file.read(buf, len)) {
Serial.println("Read failed");
return;
}
file.close();
Serial.printf("Read [%s] Complete: %s", path, buf);
}
void testIO(fs::FS &fs)
{
char buf[] = "hello world";
WriteFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
ReadFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("请插入内存卡");
delay(8000);
/* SD_MMC 1-bit Mode */
if (!SD_MMC.begin("/cdcard", true)) {
Serial.println("Card Mount Failed");
return;
}
testIO(SD_MMC);
SD_MMC.end(); // 取消SD挂载
}
void loop() {
}
#include "FS.h"
#include "SD.h"
#include "SD_MMC.h"
void WriteFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
//unsigned long start_time = millis();
Serial.printf("write [%s]...\n", path);
File file = fs.open(path, FILE_WRITE);
if (!file) {
Serial.println("Failed to open file for writing");
return;
}
if (!file.write(buf, len)) {
Serial.println("Write failed");
return;
}
file.flush();
file.close();
Serial.printf("Write [%s] Complete", path);
}
void ReadFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
Serial.printf("read [%s]...\n", path);
File file = fs.open(path);
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
if (!file.read(buf, len)) {
Serial.println("Read failed");
return;
}
file.close();
Serial.printf("Read [%s] Complete: %s", path, buf);
}
void testIO(fs::FS &fs)
{
char buf[] = "hello world";
WriteFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
ReadFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("请插入内存卡");
delay(8000);
/* SD SPI Mode at HSPI */
SPIClass spi = SPIClass(HSPI);
spi.begin(14 /* SCK */, 12 /* MISO */, 13 /* MOSI */, 15 /* SS */);
if (!SD.begin(15 /* SS */, spi, 80000000)) {
Serial.println("Card Mount Failed");
return;
}
testIO(SD);
SD_MMC.end(); // 取消SD挂载
}
void loop() {
} 采用 32GB 闪迪 TF卡出现以下问题:
#include "FS.h"
#include "SD.h"
#include "SD_MMC.h"
void WriteFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
//unsigned long start_time = millis();
Serial.printf("write [%s]...\n", path);
File file = fs.open(path, FILE_WRITE);
if (!file) {
Serial.println("Failed to open file for writing");
return;
}
if (!file.write(buf, len)) {
Serial.println("Write failed");
return;
}
file.flush();
file.close();
Serial.printf("Write [%s] Complete", path);
}
void ReadFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
Serial.printf("read [%s]...\n", path);
File file = fs.open(path);
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
if (!file.read(buf, len)) {
Serial.println("Read failed");
return;
}
file.close();
Serial.printf("Read [%s] Complete: %s", path, buf);
}
void testIO(fs::FS &fs)
{
char buf[] = "hello world";
WriteFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
ReadFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("请插入内存卡");
delay(8000);
/* SD SPI Mode at VSPI */
SPIClass spi = SPIClass(HSPI);
spi.begin(18 /* SCK */, 19 /* MISO */, 23 /* MOSI */, 5 /* SS */);
if (!SD.begin(5 /* SS */, spi, 80000000)) {
Serial.println("Card Mount Failed");
return;
}
testIO(SD);
SD_MMC.end(); // 取消SD挂载
}
void loop() {
} 采用 32GB 闪迪 TF卡出现 VSPI 同样问题,换成 32GB Kingston TF 卡正常。
电子设计自动化(英语:Electronic design automation,缩写:EDA)是指利用计算机辅助设计(CAD)软件,来完成超大规模集成电路(VLSI)芯片的功能设计、综合、验证、物理设计(包括布局、布线、版图、设计规则检查等)等流程的设计方式。
在音频处理领域,I2S是一种广泛使用的通信协议,它专门用于芯片之间的音频数据传输。ESP32 作为一款高性能的微控制器,不仅支持 I2S 通信,还提供了强大的硬件接口和灵活的软件库,使其成为音频项目开发的理想选择。
小鹏物联网智能浇花系统是照顾植物的好帮手,支持自动控制和手动控制两种模式,可通过电脑端和手机端查看数据和控制浇水。
Arduino开发环境下适用于ESP32芯片系列开发板的应用开发框架。
本小节主要介绍C++ 类相关的基础知识,包括类的定义、继承、多态,范围作用域等。
本讲主要介绍VSCode Arduino开发环境的搭建,及与Arduino IDE开发环境的比较。
本文主要讲解WebServer库如何来处理表单请求。
WebServer是非常常用的一个功能,在设备上使用该功能可以直接通过浏览器访问和操作设备。
Arduino-ESP32与ESP-IDF的版本对应表。
Arduino-ESP32提供了多种文件系统解决方案,本文将深入解析SPIFFS、LittleFS和SD卡三种主流存储方案,帮助你做出最佳选择。