You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 satır
1.4KB

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