one_wire_timings.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include <stdint.h>
  3. class __OneWireTiming {
  4. public:
  5. constexpr static const uint16_t TIMING_A = 9;
  6. constexpr static const uint16_t TIMING_B = 64;
  7. constexpr static const uint16_t TIMING_C = 64;
  8. constexpr static const uint16_t TIMING_D = 14;
  9. constexpr static const uint16_t TIMING_E = 9;
  10. constexpr static const uint16_t TIMING_F = 55;
  11. constexpr static const uint16_t TIMING_G = 0;
  12. constexpr static const uint16_t TIMING_H = 480;
  13. constexpr static const uint16_t TIMING_I = 70;
  14. constexpr static const uint16_t TIMING_J = 410;
  15. };
  16. class OneWireTiming {
  17. public:
  18. constexpr static const uint16_t WRITE_1_DRIVE = __OneWireTiming::TIMING_A;
  19. constexpr static const uint16_t WRITE_1_RELEASE = __OneWireTiming::TIMING_B;
  20. constexpr static const uint16_t WRITE_0_DRIVE = __OneWireTiming::TIMING_C;
  21. constexpr static const uint16_t WRITE_0_RELEASE = __OneWireTiming::TIMING_D;
  22. constexpr static const uint16_t READ_DRIVE = 3;
  23. constexpr static const uint16_t READ_RELEASE = __OneWireTiming::TIMING_E;
  24. constexpr static const uint16_t READ_DELAY_POST = __OneWireTiming::TIMING_F;
  25. constexpr static const uint16_t RESET_DELAY_PRE = __OneWireTiming::TIMING_G;
  26. constexpr static const uint16_t RESET_DRIVE = __OneWireTiming::TIMING_H;
  27. constexpr static const uint16_t RESET_RELEASE = __OneWireTiming::TIMING_I;
  28. constexpr static const uint16_t RESET_DELAY_POST = __OneWireTiming::TIMING_J;
  29. };
  30. typedef uint32_t OneWiteTimeType;
  31. class OneWireEmulateTiming {
  32. public:
  33. constexpr static const OneWiteTimeType RESET_MIN = 270;
  34. constexpr static const OneWiteTimeType RESET_MAX = 960;
  35. constexpr static const OneWiteTimeType PRESENCE_TIMEOUT = 20;
  36. constexpr static const OneWiteTimeType PRESENCE_MIN = 100;
  37. constexpr static const OneWiteTimeType PRESENCE_MAX = 480;
  38. constexpr static const OneWiteTimeType MSG_HIGH_TIMEOUT = 15000;
  39. constexpr static const OneWiteTimeType SLOT_MAX = 135;
  40. constexpr static const OneWiteTimeType READ_MIN = 20;
  41. constexpr static const OneWiteTimeType READ_MAX = 60;
  42. constexpr static const OneWiteTimeType WRITE_ZERO = 30;
  43. };