ngscopeclient 0.1-dev+51fbda87c
I2CEepromDecoder.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopeprotocols *
4* *
5* Copyright (c) 2012-2022 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
35#ifndef I2CEepromDecoder_h
36#define I2CEepromDecoder_h
37
38#include "../scopehal/PacketDecoder.h"
39
41{
42public:
43
44 enum EepromType
45 {
46 TYPE_SELECT_READ, //select with read bit, ack'd
47 TYPE_SELECT_WRITE, //select with write bit, ack'd
48 TYPE_POLL_BUSY, //select with read or write bit, nak'd
49 TYPE_POLL_OK, //poll success
50 TYPE_ADDRESS,
51 TYPE_DATA
52 };
53
55 {}
56
57 I2CEepromSymbol(EepromType type, uint32_t data)
58 : m_type(type)
59 , m_data(data)
60 {}
61
62 EepromType m_type;
63 uint32_t m_data;
64
65 bool operator== (const I2CEepromSymbol& s) const
66 {
67 return (m_type == s.m_type) && (m_data == s.m_data);
68 }
69};
70
71class I2CEepromWaveform : public SparseWaveform<I2CEepromSymbol>
72{
73public:
74 I2CEepromWaveform (FilterParameter& raw_bits) : SparseWaveform<I2CEepromSymbol>(), m_raw_bits(raw_bits) {};
75 virtual std::string GetText(size_t) override;
76 virtual std::string GetColor(size_t) override;
77
78private:
79 FilterParameter& m_raw_bits;
80};
81
83{
84public:
85 I2CEepromDecoder(const std::string& color);
86
87 virtual void Refresh() override;
88
89 static std::string GetProtocolName();
90
91 virtual std::vector<std::string> GetHeaders() override;
92
93 virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
94
95 virtual bool CanMerge(Packet* first, Packet* cur, Packet* next) override;
96 virtual Packet* CreateMergedHeader(Packet* pack, size_t i) override;
97
98 PROTOCOL_DECODER_INITPROC(I2CEepromDecoder)
99
100protected:
101 std::string m_memtypename;
102 std::string m_baseaddrname;
103 std::string m_addrpinname;
104};
105
106#endif
A parameter to a filter.
Definition: FilterParameter.h:86
Definition: I2CEepromDecoder.h:83
virtual bool CanMerge(Packet *first, Packet *cur, Packet *next) override
Checks if multiple packets can be merged under a single heading in the protocol analyzer view.
Definition: I2CEepromDecoder.cpp:587
virtual void Refresh() override
Evaluates a filter graph node.
Definition: I2CEepromDecoder.cpp:117
virtual Packet * CreateMergedHeader(Packet *pack, size_t i) override
Creates a summary packet for one or more merged packets.
Definition: I2CEepromDecoder.cpp:596
Definition: I2CEepromDecoder.h:41
Definition: I2CEepromDecoder.h:72
virtual std::string GetText(size_t) override
Returns the text representation of a given protocol sample.
Definition: I2CEepromDecoder.cpp:544
virtual std::string GetColor(size_t) override
Returns the displayed color (in HTML #rrggbb or #rrggbbaa notation) of a given protocol sample.
Definition: I2CEepromDecoder.cpp:517
Definition: PacketDecoder.h:85
Definition: PacketDecoder.h:40
A waveform sampled at irregular intervals.
Definition: Waveform.h:460
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46