@@ -3,6 +3,7 @@ set_property(CACHE TIMERS PROPERTY STRINGS 2 3)
|
||||
option(CLI "Command Line Interface" OFF)
|
||||
option(DEBUG "Debug mode" OFF)
|
||||
option(LOG_TELEMETRY "Telemetry Logs on SD card" OFF)
|
||||
option(LOG_BLUETOOTH "Bluetooth Logs on SD card" OFF)
|
||||
option(TRACE_SD_CARD "Traces SD enabled" OFF)
|
||||
option(TRACE_FATFS "Traces FatFS enabled" OFF)
|
||||
option(TRACE_AUDIO "Traces audio enabled" OFF)
|
||||
@@ -30,6 +31,10 @@ if(LOG_TELEMETRY)
|
||||
add_definitions(-DLOG_TELEMETRY)
|
||||
endif()
|
||||
|
||||
if(LOG_BLUETOOTH)
|
||||
add_definitions(-DLOG_BLUETOOTH)
|
||||
endif()
|
||||
|
||||
if(TRACE_SD_CARD)
|
||||
add_definitions(-DTRACE_SD_CARD)
|
||||
set(DEBUG ON)
|
||||
|
||||
@@ -310,10 +310,15 @@ DRESULT disk_ioctl (
|
||||
// TODO everything here should not be in the driver layer ...
|
||||
|
||||
FATFS g_FATFS_Obj __DMA; // initialized in boardInit()
|
||||
|
||||
#if defined(LOG_TELEMETRY)
|
||||
FIL g_telemetryFile = {};
|
||||
#endif
|
||||
|
||||
#if defined(LOG_BLUETOOTH)
|
||||
FIL g_bluetoothFile = {};
|
||||
#endif
|
||||
|
||||
#if defined(BOOT)
|
||||
void sdInit(void)
|
||||
{
|
||||
@@ -350,6 +355,13 @@ void sdMount()
|
||||
f_lseek(&g_telemetryFile, f_size(&g_telemetryFile)); // append
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LOG_BLUETOOTH)
|
||||
f_open(&g_bluetoothFile, LOGS_PATH "/bluetooth.log", FA_OPEN_ALWAYS | FA_WRITE);
|
||||
if (f_size(&g_bluetoothFile) > 0) {
|
||||
f_lseek(&g_bluetoothFile, f_size(&g_bluetoothFile)); // append
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
TRACE("f_mount() failed");
|
||||
@@ -362,9 +374,15 @@ void sdDone()
|
||||
|
||||
if (sdMounted()) {
|
||||
audioQueue.stopSD();
|
||||
|
||||
#if defined(LOG_TELEMETRY)
|
||||
f_close(&g_telemetryFile);
|
||||
#endif
|
||||
|
||||
#if defined(LOG_BLUETOOTH)
|
||||
f_close(&g_bluetoothFile);
|
||||
#endif
|
||||
|
||||
f_mount(nullptr, "", 0); // unmount SD
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,6 +214,13 @@ void sdInit(void)
|
||||
f_lseek(&g_telemetryFile, f_size(&g_telemetryFile)); // append
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LOG_BLUETOOTH)
|
||||
f_open(&g_bluetoothFile, LOGS_PATH "/bluetooth.log", FA_OPEN_ALWAYS | FA_WRITE);
|
||||
if (f_size(&g_bluetoothFile) > 0) {
|
||||
f_lseek(&g_bluetoothFile, f_size(&g_bluetoothFile)); // append
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
TRACE_SIMPGMSPACE("f_mount() failed");
|
||||
@@ -226,6 +233,9 @@ void sdDone()
|
||||
audioQueue.stopSD();
|
||||
#if defined(LOG_TELEMETRY)
|
||||
f_close(&g_telemetryFile);
|
||||
#endif
|
||||
#if defined(LOG_BLUETOOTH)
|
||||
f_close(&g_bluetoothFile);
|
||||
#endif
|
||||
f_mount(NULL, "", 0); // unmount SD
|
||||
}
|
||||
|
||||
@@ -978,10 +978,15 @@ void sdPoll10ms()
|
||||
// TODO everything here should not be in the driver layer ...
|
||||
|
||||
FATFS g_FATFS_Obj;
|
||||
|
||||
#if defined(LOG_TELEMETRY)
|
||||
FIL g_telemetryFile = {};
|
||||
#endif
|
||||
|
||||
#if defined(LOG_BLUETOOTH)
|
||||
FIL g_bluetoothFile = {};
|
||||
#endif
|
||||
|
||||
#if defined(BOOT)
|
||||
void sdInit(void)
|
||||
{
|
||||
@@ -1016,6 +1021,13 @@ void sdMount()
|
||||
f_lseek(&g_telemetryFile, f_size(&g_telemetryFile)); // append
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LOG_BLUETOOTH)
|
||||
f_open(&g_bluetoothFile, LOGS_PATH "/bluetooth.log", FA_OPEN_ALWAYS | FA_WRITE);
|
||||
if (f_size(&g_bluetoothFile) > 0) {
|
||||
f_lseek(&g_bluetoothFile, f_size(&g_bluetoothFile)); // append
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1025,6 +1037,9 @@ void sdDone()
|
||||
audioQueue.stopSD();
|
||||
#if defined(LOG_TELEMETRY)
|
||||
f_close(&g_telemetryFile);
|
||||
#endif
|
||||
#if defined(LOG_BLUETOOTH)
|
||||
f_close(&g_bluetoothFile);
|
||||
#endif
|
||||
f_mount(nullptr, "", 0); // unmount SD
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user