spi_decoder.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // // ******************************************************************
  2. // // /\ /| @File spi_decoder.h
  3. // // \ V/ @Brief
  4. // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
  5. // // / | @Creation 2024-07-19
  6. // // / \\ @Modified 2024-07-23
  7. // // *(__\_\
  8. // // ******************************************************************
  9. #pragma once
  10. #include <vector>
  11. //#include "../BaseHelper/common_helper.h"
  12. #include "../edge_pulse_data.h"
  13. #include "../edge_pulse.h"
  14. #include "../protocol_decode_base.h"
  15. #include "spi_decode_options.h"
  16. #include "spi_decode_result.h"
  17. namespace Protocol
  18. {
  19. class SpiDecoder
  20. {
  21. public:
  22. bool DecodeSpi(const SpiDecodeOptions& options,
  23. const EdgePulseDataTwoLevels& edge_pulse_data_clk,
  24. const EdgePulseDataTwoLevels& edge_pulse_data_cs,
  25. const EdgePulseDataTwoLevels& edge_pulse_data_mosi,
  26. const EdgePulseDataTwoLevels& edge_pulse_data_miso,
  27. SpiDecodeResult& decode_result);
  28. private:
  29. bool* is_cancel_ptr_ = nullptr;
  30. std::vector<SpiPacket> packet_infos_ = {};
  31. bool need_decode_data_ = false;
  32. bool need_update_view_info_ = false;
  33. //SpiEnums::FramingMode framing_mode_ = SpiEnums::FramingMode::MODE1;
  34. int frame_count_ = 8;
  35. //double idle_time_ = 0.0;
  36. int32_t data_len_ = 0;
  37. /*std::vector<uint8_t> miso_data = {};
  38. std::vector<uint8_t> mosi_data = {};*/
  39. std::vector<DataPacketInfo> data_packet_info_ = {};
  40. bool FindStartNode(int32_t& start_index, int32_t& cs_start_index, TwoLevelEdgePulse*& node_cs,
  41. TwoLevelEdgePulse*& node_clk, Polarity polarity_cs, Polarity polarity_clk) const;
  42. static bool GetCsBitNextIndex(bool state, int32_t start_index, TwoLevelEdgePulse*& node_cs);
  43. static bool GetClkEdge(bool state, int32_t& start_index, TwoLevelEdgePulse*& node_clk);
  44. };
  45. }