12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- // // ******************************************************************
- // // /\ /| @File SYNC.h
- // // \ V/ @Brief
- // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
- // // / | @Creation 2024-05-17
- // // / \\ @Modified 2024-06-24
- // // *(__\_\
- // // ******************************************************************
- #pragma once
- #include "Constants.h"
- namespace Protocol
- {
- class Sync
- {
- public:
- TwoLevelEdgePulse* node_ptr;
- int32_t end_index;
- int32_t single_bit_timing_length;
- int32_t one_byte_timing_length;
- int32_t Length() const
- {
- if (node_ptr == nullptr || node_ptr->start_index < 0)
- {
- return 0;
- }
- return end_index - node_ptr->start_index;
- }
- int32_t PacketEndIndex() const
- {
- return packetEndIndex;
- }
- void SetPacketEndIndex(const int32_t value)
- {
- packetEndIndex = value;
- }
- Sync() : node_ptr(nullptr), end_index(0), single_bit_timing_length(0), one_byte_timing_length(0), packetEndIndex(0)
- {
- }
- Sync(TwoLevelEdgePulse* node_ptr,const int end_index, const int32_t single_bit_timing_length, const bool is_high_speed) : node_ptr(node_ptr),
- end_index(end_index),
- single_bit_timing_length(single_bit_timing_length),
- one_byte_timing_length(single_bit_timing_length * USB_BYTE_BIT_COUNT),
- packetEndIndex(0)
- {
- const int32_t sync_byte_len = is_high_speed ? USB_USB_SYNC_BIT_MAX_LEN : USB_BYTE_BIT_COUNT;
- const int32_t fix_sync_end_index = node_ptr->start_index + static_cast<int32_t>(single_bit_timing_length * sync_byte_len
- * USB_SYNC_BIT_TOL);
- if (end_index < fix_sync_end_index)
- {
- this->end_index = fix_sync_end_index;
- }
- }
- private:
- int32_t packetEndIndex;
- };
- }
|