OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [tools/] [src/] [librlink/] [RlinkPacketBuf.ipp] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 wfjm
// $Id: RlinkPacketBuf.ipp 488 2013-02-16 18:49:47Z mueller $
2 10 wfjm
//
3
// Copyright 2011- by Walter F.J. Mueller 
4
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
//
14
// Revision History:
15
// Date         Rev Version  Comment
16
// 2011-04-02   375   1.0    Initial version
17
// 2011-03-05   366   0.1    First draft
18
// ---------------------------------------------------------------------------
19
 
20
/*!
21
  \file
22 19 wfjm
  \version $Id: RlinkPacketBuf.ipp 488 2013-02-16 18:49:47Z mueller $
23 10 wfjm
  \brief   Implemenation (inline) of class RlinkPacketBuf.
24
*/
25
 
26 19 wfjm
// all method definitions in namespace Retro
27 10 wfjm
namespace Retro {
28
 
29
//------------------------------------------+-----------------------------------
30
//! FIXME_docs
31
 
32
inline void RlinkPacketBuf::PutWithCrc(uint8_t data)
33
{
34
  fPktBuf.push_back(data);
35
  fCrc.AddData(data);
36
  return;
37
}
38
 
39
//------------------------------------------+-----------------------------------
40
//! FIXME_docs
41
 
42
inline void RlinkPacketBuf::PutWithCrc(uint16_t data)
43
{
44
  PutWithCrc((uint8_t)( data     & 0xff)); // lsb first
45
  PutWithCrc((uint8_t)((data>>8) & 0xff));
46
  return;
47
}
48
 
49
//------------------------------------------+-----------------------------------
50
//! FIXME_docs
51
 
52
inline void RlinkPacketBuf::PutCrc()
53
{
54
  fPktBuf.push_back(fCrc.Crc());
55
  return;
56
}
57
 
58
//------------------------------------------+-----------------------------------
59
//! FIXME_docs
60
 
61
inline bool RlinkPacketBuf::CheckSize(size_t nbyte) const
62
{
63
  return fPktBuf.size()-fNdone >= nbyte;
64
}
65
 
66
//------------------------------------------+-----------------------------------
67
//! FIXME_docs
68
 
69
inline uint8_t RlinkPacketBuf::Get8WithCrc()
70
{
71
  uint8_t data = fPktBuf[fNdone++];
72
  fCrc.AddData(data);
73
  return data;
74
}
75
 
76
//------------------------------------------+-----------------------------------
77
//! FIXME_docs
78
 
79
inline uint16_t RlinkPacketBuf::Get16WithCrc()
80
{
81
  uint8_t datl = fPktBuf[fNdone++];
82
  uint8_t dath = fPktBuf[fNdone++];
83
  fCrc.AddData(datl);
84
  fCrc.AddData(dath);
85
  return (uint16_t)datl | ((uint16_t)dath << 8);
86
}
87
 
88
//------------------------------------------+-----------------------------------
89
//! FIXME_docs
90
 
91
inline bool RlinkPacketBuf::CheckCrc()
92
{
93
  uint8_t data = fPktBuf[fNdone++];
94
  return data == fCrc.Crc();
95
}
96
 
97
//------------------------------------------+-----------------------------------
98
//! FIXME_docs
99
 
100
inline size_t RlinkPacketBuf::PktSize() const
101
{
102
  return fPktBuf.size();
103
}
104
 
105
//------------------------------------------+-----------------------------------
106
//! FIXME_docs
107
 
108
inline size_t RlinkPacketBuf::RawSize() const
109
{
110
  return fRawBuf.size();
111
}
112
 
113
//------------------------------------------+-----------------------------------
114
//! FIXME_docs
115
 
116
inline void RlinkPacketBuf::SetFlagBit(uint32_t mask)
117
{
118
  fFlags |= mask;
119
  return;
120
}
121
 
122
//------------------------------------------+-----------------------------------
123
//! FIXME_docs
124
 
125
inline uint32_t RlinkPacketBuf::Flags() const
126
{
127
  return fFlags;
128
}
129
 
130
//------------------------------------------+-----------------------------------
131
//! FIXME_docs
132
 
133
inline bool RlinkPacketBuf::TestFlag(uint32_t mask) const
134
{
135
  return (fFlags & mask) != 0;
136
}
137
 
138
//------------------------------------------+-----------------------------------
139
//! FIXME_docs
140
 
141
inline size_t RlinkPacketBuf::Nesc() const
142
{
143
  return fNesc;
144
}
145
 
146
//------------------------------------------+-----------------------------------
147
//! FIXME_docs
148
 
149
inline size_t RlinkPacketBuf::Nattn() const
150
{
151
  return fNattn;
152
}
153
 
154
//------------------------------------------+-----------------------------------
155
//! FIXME_docs
156
 
157
inline size_t RlinkPacketBuf::Nidle() const
158
{
159
  return fNidle;
160
}
161
 
162
//------------------------------------------+-----------------------------------
163
//! FIXME_docs
164
 
165
inline size_t RlinkPacketBuf::Ndrop() const
166
{
167
  return fNdrop;
168
}
169
 
170
//------------------------------------------+-----------------------------------
171
//! FIXME_docs
172
 
173
inline void RlinkPacketBuf::ClearFlagBit(uint32_t mask)
174
{
175
  fFlags &= ~mask;
176
  return;
177
}
178
 
179
} // end namespace Retro

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.