#include "log_api.h" #include "log.h" #include "rtc.h" #include "ringfs.h" #include "spi_flash.h" #include "FreeRTOS.h" #include "task.h" #include "semphr.h" #include "rtc.h" #include #include #include #undef DBG #define DBG if(1) extern struct ringfs fs_archive; extern SemaphoreHandle_t log_mutex; // void log_get_entry_count(void) { int count_flash = 0; count_flash = ringfs_count_exact(&fs_archive); printf("Count archive entry: %u\r\n", count_flash); } // int log_get_entry(uint32_t index, struct ringfs *fs) { archive_entry_t entry; int start = ringfs_count_estimate(fs); fs->cursor_position = start - (index - 1) - 1; if (fs->cursor_position < 0) return -1; else { fs->cursor.sector = (fs->read.sector + fs->cursor_position/fs->slots_per_sector)%fs->flash->sector_count; fs->cursor.slot = fs->cursor_position%fs->slots_per_sector; } log_fetch(&entry, ARCHIVE_ENTRY, portMAX_DELAY); printf("[entry] timestamp = % " PRId64 ", value = %u, crc = %u\r\n", entry.timestamp, entry.input_value, entry.crc); return 0; }