altos: Flush the on-board mega log after every sample interval.
authorKeith Packard <keithp@keithp.com>
Mon, 1 Apr 2013 08:58:37 +0000 (01:58 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 1 Apr 2013 08:58:37 +0000 (01:58 -0700)
SPI flash parts don't need flushing, but the SD card does. Make sure
the SD card contents are sane after every logging interval has passed
by flushing all dirty blocks to the device.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/core/ao_log.h
src/core/ao_log_mega.c
src/drivers/ao_log_fat.c

index 036d6f2de56c134ab445c85b5b709c7e019a5076..cac787715af95f297f0cfcfd7f8e26afd87ffa1c 100644 (file)
@@ -268,4 +268,7 @@ ao_log_data(__xdata struct ao_log_record *log) __reentrant;
 uint8_t
 ao_log_mega(__xdata struct ao_log_mega *log) __reentrant;
 
+void
+ao_log_flush(void);
+
 #endif /* _AO_LOG_H_ */
index e03687ada912d8352527179caa9117e8645bd630..ba3f7bfc22729a42b3920e89c5e1dab90aad2e56 100644 (file)
@@ -171,6 +171,8 @@ ao_log(void)
                }
 #endif
 
+               ao_log_flush();
+
                /* Wait for a while */
                ao_delay(AO_MS_TO_TICKS(100));
 
index 2741555f29e417a61a88c1003f8b540f910b3fcf..6b433b991c03e2f0081f344efc51c6e50dbf4089 100644 (file)
@@ -83,3 +83,9 @@ ao_log_mega(struct ao_log_mega *log)
        ao_mutex_put(&log_mutex);
        return wrote;
 }
+
+void
+ao_log_flush(void)
+{
+       ao_fat_sync();
+}