one_wire_timings.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #include <stdint.h>
  3. class __OneWireTiming {
  4. public:
  5. constexpr static const uint16_t TIMING_A = 6;
  6. constexpr static const uint16_t TIMING_B = 64;
  7. constexpr static const uint16_t TIMING_C = 60;
  8. constexpr static const uint16_t TIMING_D = 10;
  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 = __OneWireTiming::TIMING_A;
  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_TIMEOUT = {5000};
  34. constexpr static const OneWiteTimeType RESET_MIN[2] = {430, 48};
  35. constexpr static const OneWiteTimeType RESET_MAX[2] = {960, 80};
  36. constexpr static const OneWiteTimeType PRESENCE_TIMEOUT = {20};
  37. constexpr static const OneWiteTimeType PRESENCE_MIN[2] = {160, 8};
  38. constexpr static const OneWiteTimeType PRESENCE_MAX[2] = {480, 32};
  39. constexpr static const OneWiteTimeType MSG_HIGH_TIMEOUT = {15000};
  40. constexpr static const OneWiteTimeType SLOT_MAX[2] = {135, 30};
  41. constexpr static const OneWiteTimeType READ_MIN[2] = {20, 4};
  42. constexpr static const OneWiteTimeType READ_MAX[2] = {60, 10};
  43. constexpr static const OneWiteTimeType WRITE_ZERO[2] = {30, 8};
  44. };