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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [tools/] [src/] [librlink/] [RlinkPacketBuf.ipp] - Diff between revs 19 and 26

Only display areas with differences | Details | Blame | View Log

Rev 19 Rev 26
// $Id: RlinkPacketBuf.ipp 488 2013-02-16 18:49:47Z mueller $
// $Id: RlinkPacketBuf.ipp 488 2013-02-16 18:49:47Z mueller $
//
//
// Copyright 2011- by Walter F.J. Mueller 
// Copyright 2011- by Walter F.J. Mueller 
//
//
// This program is free software; you may redistribute and/or modify it under
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
// the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 2, or at your option any later version.
// Software Foundation, either version 2, or at your option any later version.
//
//
// This program is distributed in the hope that it will be useful, but
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for complete details.
// for complete details.
//
//
// Revision History:
// Revision History:
// Date         Rev Version  Comment
// Date         Rev Version  Comment
// 2011-04-02   375   1.0    Initial version
// 2011-04-02   375   1.0    Initial version
// 2011-03-05   366   0.1    First draft
// 2011-03-05   366   0.1    First draft
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*!
/*!
  \file
  \file
  \version $Id: RlinkPacketBuf.ipp 488 2013-02-16 18:49:47Z mueller $
  \version $Id: RlinkPacketBuf.ipp 488 2013-02-16 18:49:47Z mueller $
  \brief   Implemenation (inline) of class RlinkPacketBuf.
  \brief   Implemenation (inline) of class RlinkPacketBuf.
*/
*/
// all method definitions in namespace Retro
// all method definitions in namespace Retro
namespace Retro {
namespace Retro {
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline void RlinkPacketBuf::PutWithCrc(uint8_t data)
inline void RlinkPacketBuf::PutWithCrc(uint8_t data)
{
{
  fPktBuf.push_back(data);
  fPktBuf.push_back(data);
  fCrc.AddData(data);
  fCrc.AddData(data);
  return;
  return;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline void RlinkPacketBuf::PutWithCrc(uint16_t data)
inline void RlinkPacketBuf::PutWithCrc(uint16_t data)
{
{
  PutWithCrc((uint8_t)( data     & 0xff)); // lsb first
  PutWithCrc((uint8_t)( data     & 0xff)); // lsb first
  PutWithCrc((uint8_t)((data>>8) & 0xff));
  PutWithCrc((uint8_t)((data>>8) & 0xff));
  return;
  return;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline void RlinkPacketBuf::PutCrc()
inline void RlinkPacketBuf::PutCrc()
{
{
  fPktBuf.push_back(fCrc.Crc());
  fPktBuf.push_back(fCrc.Crc());
  return;
  return;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline bool RlinkPacketBuf::CheckSize(size_t nbyte) const
inline bool RlinkPacketBuf::CheckSize(size_t nbyte) const
{
{
  return fPktBuf.size()-fNdone >= nbyte;
  return fPktBuf.size()-fNdone >= nbyte;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline uint8_t RlinkPacketBuf::Get8WithCrc()
inline uint8_t RlinkPacketBuf::Get8WithCrc()
{
{
  uint8_t data = fPktBuf[fNdone++];
  uint8_t data = fPktBuf[fNdone++];
  fCrc.AddData(data);
  fCrc.AddData(data);
  return data;
  return data;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline uint16_t RlinkPacketBuf::Get16WithCrc()
inline uint16_t RlinkPacketBuf::Get16WithCrc()
{
{
  uint8_t datl = fPktBuf[fNdone++];
  uint8_t datl = fPktBuf[fNdone++];
  uint8_t dath = fPktBuf[fNdone++];
  uint8_t dath = fPktBuf[fNdone++];
  fCrc.AddData(datl);
  fCrc.AddData(datl);
  fCrc.AddData(dath);
  fCrc.AddData(dath);
  return (uint16_t)datl | ((uint16_t)dath << 8);
  return (uint16_t)datl | ((uint16_t)dath << 8);
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline bool RlinkPacketBuf::CheckCrc()
inline bool RlinkPacketBuf::CheckCrc()
{
{
  uint8_t data = fPktBuf[fNdone++];
  uint8_t data = fPktBuf[fNdone++];
  return data == fCrc.Crc();
  return data == fCrc.Crc();
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline size_t RlinkPacketBuf::PktSize() const
inline size_t RlinkPacketBuf::PktSize() const
{
{
  return fPktBuf.size();
  return fPktBuf.size();
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline size_t RlinkPacketBuf::RawSize() const
inline size_t RlinkPacketBuf::RawSize() const
{
{
  return fRawBuf.size();
  return fRawBuf.size();
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline void RlinkPacketBuf::SetFlagBit(uint32_t mask)
inline void RlinkPacketBuf::SetFlagBit(uint32_t mask)
{
{
  fFlags |= mask;
  fFlags |= mask;
  return;
  return;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline uint32_t RlinkPacketBuf::Flags() const
inline uint32_t RlinkPacketBuf::Flags() const
{
{
  return fFlags;
  return fFlags;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline bool RlinkPacketBuf::TestFlag(uint32_t mask) const
inline bool RlinkPacketBuf::TestFlag(uint32_t mask) const
{
{
  return (fFlags & mask) != 0;
  return (fFlags & mask) != 0;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline size_t RlinkPacketBuf::Nesc() const
inline size_t RlinkPacketBuf::Nesc() const
{
{
  return fNesc;
  return fNesc;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline size_t RlinkPacketBuf::Nattn() const
inline size_t RlinkPacketBuf::Nattn() const
{
{
  return fNattn;
  return fNattn;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline size_t RlinkPacketBuf::Nidle() const
inline size_t RlinkPacketBuf::Nidle() const
{
{
  return fNidle;
  return fNidle;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline size_t RlinkPacketBuf::Ndrop() const
inline size_t RlinkPacketBuf::Ndrop() const
{
{
  return fNdrop;
  return fNdrop;
}
}
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
inline void RlinkPacketBuf::ClearFlagBit(uint32_t mask)
inline void RlinkPacketBuf::ClearFlagBit(uint32_t mask)
{
{
  fFlags &= ~mask;
  fFlags &= ~mask;
  return;
  return;
}
}
} // end namespace Retro
} // end namespace Retro
 
 

powered by: WebSVN 2.1.0

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