Disable power-down interupt in SD-logger code (#3481)

This commit is contained in:
Christophe De Wagter
2025-06-25 12:37:49 +02:00
committed by GitHub
parent e34b42cd7f
commit 993198a418
3 changed files with 14 additions and 2 deletions
+3 -1
View File
@@ -8,9 +8,10 @@
<firmware name="fixedwing"> <firmware name="fixedwing">
<configure name="USE_MAGNETOMETER" value="TRUE"/> <configure name="USE_MAGNETOMETER" value="TRUE"/>
<define name="USE_BAROMETER" value="TRUE"/>
<target name="ap" board="px4fmu_5.0_chibios"> <target name="ap" board="px4fmu_5.0_chibios">
<define name="USE_BARO_BOARD" value="1"/> <define name="USE_BARO_BOARD" value="TRUE"/>
<configure name="PERIODIC_FREQUENCY" value="120"/> <configure name="PERIODIC_FREQUENCY" value="120"/>
<module name="radio_control" type="sbus"> <module name="radio_control" type="sbus">
<configure name="SBUS_PORT" value="UART3"/> <configure name="SBUS_PORT" value="UART3"/>
@@ -51,6 +52,7 @@
</module> </module>
<!-- Logger --> <!-- Logger -->
<define name="SDLOG_ENABLE_LOWBAT_FLUSH" value="FALSE"/>
<module name="tlsf"/> <module name="tlsf"/>
<module name="pprzlog"/> <module name="pprzlog"/>
<module name="logger" type="sd_chibios"/> <module name="logger" type="sd_chibios"/>
+1
View File
@@ -15,6 +15,7 @@
<define name="SDLOG_AUTO_FLUSH_PERIOD" value="10" unit="s" description="Data flush period. Shorter period may decrease performances. Default: 10s"/> <define name="SDLOG_AUTO_FLUSH_PERIOD" value="10" unit="s" description="Data flush period. Shorter period may decrease performances. Default: 10s"/>
<define name="SDLOG_CONTIGUOUS_STORAGE_MEM" value="50" unit="Mo" description="Try to reserve a given contiguous mass storage memory. Default: 50Mo"/> <define name="SDLOG_CONTIGUOUS_STORAGE_MEM" value="50" unit="Mo" description="Try to reserve a given contiguous mass storage memory. Default: 50Mo"/>
<define name="SDLOG_PREFLIGHT_ERROR" value="FALSE" description="If set to TRUE, the autopilot will not arm if the SDLogger is not running. Default: FALSE"/> <define name="SDLOG_PREFLIGHT_ERROR" value="FALSE" description="If set to TRUE, the autopilot will not arm if the SDLogger is not running. Default: FALSE"/>
<define name="SDLOG_ENABLE_LOWBAT_FLUSH" value="TRUE" description="If set to TRUE or undefined, the autopilot will flush the buffer on detecting low voltage by ADC."/>
</doc> </doc>
<settings> <settings>
<dl_settings> <dl_settings>
+10 -1
View File
@@ -57,6 +57,12 @@
#define SDLOG_CONTIGUOUS_STORAGE_MEM 50 #define SDLOG_CONTIGUOUS_STORAGE_MEM 50
#endif #endif
// Flush file on power loss
#ifndef SDLOG_ENABLE_LOWBAT_FLUSH
#define SDLOG_ENABLE_LOWBAT_FLUSH TRUE
#endif
#if (!defined USE_ADC_WATCHDOG) || (USE_ADC_WATCHDOG == 0) #if (!defined USE_ADC_WATCHDOG) || (USE_ADC_WATCHDOG == 0)
#error sdlog_chibios need USE_ADC_WATCHDOG in order to properly close files when power is unplugged #error sdlog_chibios need USE_ADC_WATCHDOG in order to properly close files when power is unplugged
#endif #endif
@@ -233,6 +239,7 @@ void sdlog_chibios_finish(const bool flush)
/* /*
* Bat survey thread * Bat survey thread
*/ */
#if SDLOG_ENABLE_LOWBAT_FLUSH
static THD_WORKING_AREA(wa_thd_bat_survey, 1024); static THD_WORKING_AREA(wa_thd_bat_survey, 1024);
static __attribute__((noreturn)) void thd_bat_survey(void *arg); static __attribute__((noreturn)) void thd_bat_survey(void *arg);
static void powerOutageIsr(void); static void powerOutageIsr(void);
@@ -242,6 +249,7 @@ event_listener_t powerOutageListener;
#define DefaultAdcOfVoltage(voltage) ((uint32_t) (voltage/(DefaultVoltageOfAdc(1)))) #define DefaultAdcOfVoltage(voltage) ((uint32_t) (voltage/(DefaultVoltageOfAdc(1))))
static const uint16_t V_ALERT = DefaultAdcOfVoltage(5.5f); static const uint16_t V_ALERT = DefaultAdcOfVoltage(5.5f);
/* /*
powerOutageIsr is called within a lock zone from an isr, so no lock/unlock is needed powerOutageIsr is called within a lock zone from an isr, so no lock/unlock is needed
*/ */
@@ -277,6 +285,7 @@ static void thd_bat_survey(void *arg)
chThdExit(0); chThdExit(0);
while (true); // never goes here, only to avoid compiler warning: 'noreturn' function does return while (true); // never goes here, only to avoid compiler warning: 'noreturn' function does return
} }
#endif // SDLOG_ENABLE_LOWBAT_FLUSH
#endif #endif
static void thd_startlog(void *arg) static void thd_startlog(void *arg)
@@ -320,7 +329,7 @@ static void thd_startlog(void *arg)
} }
if (sdOk) { if (sdOk) {
#if defined(SDLOG_BAT_ADC) && defined(SDLOG_BAT_CHAN) #if defined(SDLOG_BAT_ADC) && defined(SDLOG_BAT_CHAN) && SDLOG_ENABLE_LOWBAT_FLUSH
// Create Battery Survey Thread with event // Create Battery Survey Thread with event
chEvtObjectInit(&powerOutageSource); chEvtObjectInit(&powerOutageSource);
chThdCreateStatic(wa_thd_bat_survey, sizeof(wa_thd_bat_survey), chThdCreateStatic(wa_thd_bat_survey, sizeof(wa_thd_bat_survey),