439a379945
2. 修改wifi与蓝牙的驱动代码,并且进行了测试,测试通过 3. 新增分区表,为板载16M的flash作分区规划,预留ota分区 4. 测试了SD卡的驱动,正常读出数据,测试通过 5. 新增了CMake配置,just_monitor(monitor_only.sh),只监视,无编译,无烧录
136 lines
3.6 KiB
C
136 lines
3.6 KiB
C
//
|
|
// Created by misaki on 2025/8/23.
|
|
//
|
|
|
|
#include <esp_log.h>
|
|
|
|
|
|
#include "I2C_Driver.h"
|
|
#include "QMI8658.h"
|
|
extern IMUdata Accel;
|
|
extern IMUdata Gyro;
|
|
void imu_test(void)
|
|
{
|
|
I2C_Init();
|
|
QMI8658_Init();
|
|
while (1) {
|
|
QMI8658_Loop();
|
|
ESP_LOGI("app_main", "Accel x: %f, y: %f, z: %f", Accel.x, Accel.y, Accel.z);
|
|
ESP_LOGD("app_main", "Gyro X: %f, Y: %f, Z: %f", Gyro.x, Gyro.y, Gyro.z);
|
|
}
|
|
}
|
|
|
|
#include "BAT_Driver.h"
|
|
void battery_test(void)
|
|
{
|
|
// 初始化电池驱动
|
|
BAT_Init();
|
|
|
|
while(1) {
|
|
float voltage = BAT_Get_Volts();
|
|
ESP_LOGI("BAT_TEST", "Battery Voltage: %.2f V", voltage);
|
|
|
|
// 电池状态判断
|
|
if (voltage > 4.0) {
|
|
ESP_LOGI("BAT_TEST", "Battery Status: Full");
|
|
} else if (voltage > 3.7) {
|
|
ESP_LOGI("BAT_TEST", "Battery Status: Good");
|
|
} else if (voltage > 3.4) {
|
|
ESP_LOGI("BAT_TEST", "Battery Status: Low");
|
|
} else {
|
|
ESP_LOGI("BAT_TEST", "Battery Status: Critical");
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#include "Wireless.h"
|
|
void wireless_test(void)
|
|
{
|
|
printf("Starting wireless scan test...\n");
|
|
|
|
// 初始化无线模块
|
|
Wireless_Init();
|
|
|
|
// 等待扫描完成
|
|
while (!Scan_finish) {
|
|
printf("Waiting for scan to complete...\n");
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
}
|
|
|
|
// 打印所有WiFi AP信息
|
|
wireless_print_wifi_aps();
|
|
|
|
// 打印所有BLE设备信息
|
|
wireless_print_ble_devices();
|
|
}
|
|
|
|
|
|
#include "SD_MMC.h"
|
|
void sd_card_module_test(void)
|
|
{
|
|
printf("\n=== 开始SD卡模块测试 ===\n\n");
|
|
|
|
// 1. 初始化SD卡
|
|
printf("1. 初始化SD卡...\n");
|
|
SD_Init();
|
|
if(SDCard_Size > 0) {
|
|
printf(" SD卡初始化成功,容量: %lu MB\n", SDCard_Size);
|
|
} else {
|
|
printf(" SD卡初始化失败!\n");
|
|
return; // 如果SD卡初始化失败,终止测试
|
|
}
|
|
|
|
// 2. 获取Flash大小
|
|
printf("2. 获取Flash大小...\n");
|
|
Flash_Searching();
|
|
printf(" Flash大小: %lu MB\n", Flash_Size);
|
|
|
|
// 3. 测试文件写入
|
|
printf("3. 测试文件写入...\n");
|
|
char test_file_path[] = MOUNT_POINT"/test.txt";
|
|
char test_data[] = "这是一段测试数据,用于验证SD卡写入功能。";
|
|
esp_err_t write_result = s_example_write_file(test_file_path, test_data);
|
|
if(write_result == ESP_OK) {
|
|
printf(" 文件写入成功: %s\n", test_file_path);
|
|
} else {
|
|
printf(" 文件写入失败!\n");
|
|
}
|
|
|
|
// 4. 测试文件读取
|
|
printf("4. 测试文件读取...\n");
|
|
esp_err_t read_result = s_example_read_file(test_file_path);
|
|
if(read_result != ESP_OK) {
|
|
printf(" 文件读取失败!\n");
|
|
}
|
|
|
|
// 5. 测试文件打开功能
|
|
printf("5. 测试文件打开功能...\n");
|
|
FILE* test_file = Open_File(test_file_path);
|
|
if(test_file != NULL) {
|
|
printf(" 文件打开成功\n");
|
|
fclose(test_file); // 记得关闭文件
|
|
} else {
|
|
printf(" 文件打开失败!\n");
|
|
}
|
|
|
|
// 6. 测试文件夹检索功能
|
|
printf("6. 测试文件夹检索功能...\n");
|
|
char file_names[10][100]; // 存储最多10个文件名
|
|
uint16_t file_count = Folder_retrieval(MOUNT_POINT, ".txt", file_names, 10);
|
|
printf(" 找到 %d 个txt文件:\n", file_count);
|
|
for(int i = 0; i < file_count; i++) {
|
|
printf(" %d. %s\n", i+1, file_names[i]);
|
|
}
|
|
|
|
// 7. 清理测试文件
|
|
printf("7. 清理测试文件...\n");
|
|
if(remove(test_file_path)) {
|
|
printf(" 删除文件失败: %s\n", test_file_path);
|
|
} else {
|
|
printf(" 成功删除测试文件: %s\n", test_file_path);
|
|
}
|
|
|
|
printf("\n=== SD卡模块测试完成 ===\n");
|
|
} |