AvrAdcLogger.h 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. #ifndef AnalogBinLogger_h
  2. #define AnalogBinLogger_h
  3. const size_t BLOCK_SIZE = 64;
  4. //------------------------------------------------------------------------------
  5. // First block of file.
  6. const size_t PIN_NUM_DIM =
  7. BLOCK_SIZE - 3 * sizeof(uint32_t) - 2 * sizeof(uint8_t);
  8. struct metadata_t {
  9. uint32_t adcFrequency; // ADC clock frequency
  10. uint32_t cpuFrequency; // CPU clock frequency
  11. uint32_t sampleInterval; // Sample interval in CPU cycles.
  12. uint8_t recordEightBits; // Size of ADC values, nonzero for 8-bits.
  13. uint8_t pinCount; // Number of analog pins in a sample.
  14. uint8_t pinNumber[PIN_NUM_DIM]; // List of pin numbers in a sample.
  15. };
  16. //------------------------------------------------------------------------------
  17. // Data block for 8-bit ADC mode.
  18. const size_t DATA_DIM8 = (BLOCK_SIZE - 2 * sizeof(uint16_t)) / sizeof(uint8_t);
  19. struct block8_t {
  20. uint16_t count; // count of data values
  21. uint16_t overrun; // count of overruns since last block
  22. uint8_t data[DATA_DIM8];
  23. };
  24. //------------------------------------------------------------------------------
  25. // Data block for 10-bit ADC mode.
  26. const size_t DATA_DIM16 =
  27. (BLOCK_SIZE - 2 * sizeof(uint16_t)) / sizeof(uint16_t);
  28. struct block16_t {
  29. unsigned short count; // count of data values
  30. unsigned short overrun; // count of overruns since last block
  31. unsigned short data[DATA_DIM16];
  32. };
  33. #endif // AnalogBinLogger_h