log_api.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "log_api.h"
  2. #include "log.h"
  3. #include "rtc.h"
  4. #include "ringfs.h"
  5. #include "spi_flash.h"
  6. #include "FreeRTOS.h"
  7. #include "task.h"
  8. #include "semphr.h"
  9. #include "rtc.h"
  10. #include <string.h>
  11. #include <stdio.h>
  12. #include <inttypes.h>
  13. #undef DBG
  14. #define DBG if(1)
  15. extern struct ringfs fs_archive;
  16. //
  17. void log_get_entry_count(entry_type_t entry_type)
  18. {
  19. int count_flash = 0;
  20. count_flash = ringfs_count_exact(&fs_archive);
  21. printf("Count archive entry: %u\r\n", count_flash);
  22. }
  23. //
  24. //void log_get_entry(uint32_t position)
  25. void log_get_entry(uint32_t position, uint32_t sector, uint32_t slot)
  26. {
  27. archive_entry_t entry = {0};
  28. int cur_position = fs_archive.cursor_position = position;
  29. int cur_sector = fs_archive.cursor.sector;
  30. int cur_slot = fs_archive.cursor.slot;
  31. fs_archive.cursor_position = position;
  32. fs_archive.cursor.sector = sector;
  33. fs_archive.cursor.slot = slot;
  34. log_fetch(&entry, ARCHIVE_ENTRY, portMAX_DELAY);
  35. fs_archive.cursor_position = cur_position;
  36. fs_archive.cursor.sector = cur_sector;
  37. fs_archive.cursor.slot = cur_slot;
  38. printf("[entry] timestamp = % " PRId64 ", value = %u, crc = %u\r\n", entry.timestamp, entry.input_value, entry.crc);
  39. }