/usr/include/lime/LMS64CProtocol.h is in liblimesuite-dev 16.12.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | /**
@file LMS64CProtocol.h
@author Lime Microsystems
@brief Implementation of LMS64C protocol.
*/
#pragma once
#include <IConnection.h>
#include <mutex>
#include <LMS64CCommands.h>
#include <LMSBoards.h>
namespace lime{
/*!
* Implement the LMS64CProtocol.
* The LMS64CProtocol is an IConnection that implements
* configuration and spi access over the LMS64C Protocol.
* Connections using LMS64C may inherit from LMS64C.
*/
class LMS64CProtocol : public virtual IConnection
{
public:
LMS64CProtocol(void);
virtual ~LMS64CProtocol(void);
DeviceInfo GetDeviceInfo(void);
//! DeviceReset implemented by LMS64C
int DeviceReset(void);
//! TransactSPI implemented by LMS64C
int TransactSPI(const int addr, const uint32_t *writeData, uint32_t *readData, const size_t size);
//! WriteI2C implemented by LMS64C
int WriteI2C(const int addr, const std::string &data);
//! ReadI2C implemented by LMS64C
int ReadI2C(const int addr, const size_t numBytes, std::string &data);
//! WriteRegisters (BRDSPI) implemented by LMS64C
int WriteRegisters(const uint32_t *addrs, const uint32_t *data, const size_t size);
//! ReadRegisters (BRDSPI) implemented by LMS64C
int ReadRegisters(const uint32_t *addrs, uint32_t *data, const size_t size);
//! Get the last-set reference clock rate
double GetReferenceClockRate(void);
/*!
* Set the reference using the Si5351C when available
*/
int SetReferenceClockRate(const double rate);
/// Supported connection types.
enum eConnectionType
{
CONNECTION_UNDEFINED = -1,
COM_PORT = 0,
USB_PORT = 1,
SPI_PORT = 2,
PCIE_PORT = 3,
//insert new types here
CONNECTION_TYPES_COUNT //used only for memory allocation
};
enum eLMS_PROTOCOL
{
LMS_PROTOCOL_UNDEFINED = 0,
LMS_PROTOCOL_DIGIC,
LMS_PROTOCOL_LMS64C,
LMS_PROTOCOL_NOVENA,
};
struct GenericPacket
{
GenericPacket()
{
cmd = CMD_GET_INFO;
status = STATUS_UNDEFINED;
}
eCMD_LMS cmd;
eCMD_STATUS status;
std::vector<unsigned char> outBuffer;
std::vector<unsigned char> inBuffer;
};
struct ProtocolDIGIC
{
static const int pktLength = 64;
static const int maxDataLength = 60;
ProtocolDIGIC() : cmd(0), i2cAddr(0), blockCount(0) {};
unsigned char cmd;
unsigned char i2cAddr;
unsigned char blockCount;
unsigned char reserved;
unsigned char data[maxDataLength];
};
struct ProtocolLMS64C
{
static const int pktLength = 64;
static const int maxDataLength = 56;
ProtocolLMS64C() :cmd(0),status(STATUS_UNDEFINED),blockCount(0)
{
memset(reserved, 0, 5);
};
unsigned char cmd;
unsigned char status;
unsigned char blockCount;
unsigned char reserved[5];
unsigned char data[maxDataLength];
};
struct ProtocolNovena
{
static const int pktLength = 128;
static const int maxDataLength = 128;
ProtocolNovena() :cmd(0),status(0) {};
unsigned char cmd;
unsigned char status;
unsigned char blockCount;
unsigned char data[maxDataLength];
};
/*!
* Transfer a packet over the underlying transport layer.
* TransferPacket performs a request/response
* using the GenericPacket data structure.
* Some implementations will cast to LMS64CProtocol
* and directly use the TransferPacket() API call.
*/
virtual int TransferPacket(GenericPacket &pkt);
struct LMSinfo
{
eLMS_DEV device;
eEXP_BOARD expansion;
int firmware;
int hardware;
int protocol;
uint64_t boardSerialNumber;
};
LMSinfo GetInfo();
struct FPGAinfo
{
int boardID;
int gatewareVersion;
int gatewareRevision;
};
FPGAinfo GetFPGAInfo();
//! implement in base class
virtual eConnectionType GetType(void) = 0;
//! virtual write function to be implemented by the base class
virtual int Write(const unsigned char *buffer, int length, int timeout_ms = 100) = 0;
//! virtual read function to be implemented by the base class
virtual int Read(unsigned char *buffer, int length, int timeout_ms = 100) = 0;
enum ProgramWriteTarget
{
HPM,
FX3, //
FPGA, // prog_modes: 0-bitstream to FPGA, 1-to FLASH, 2-bitstream from FLASH
PROGRAM_WRITE_TARGET_COUNT
};
virtual int ProgramWrite(const char *buffer, const size_t length, const int programmingMode, const int device, ProgrammingCallback callback = nullptr);
virtual int CustomParameterRead(const uint8_t *ids, double *values, const size_t count, std::string* units);
virtual int CustomParameterWrite(const uint8_t *ids, const double *values, const size_t count, const std::string* units);
virtual int GPIOWrite(const uint8_t *buffer, const size_t bufLength);
virtual int GPIORead(uint8_t *buffer, const size_t bufLength);
int ProgramMCU(const uint8_t *buffer, const size_t length, const MCU_PROG_MODE mode, ProgrammingCallback callback) override;
private:
int WriteLMS7002MSPI(const uint32_t *writeData, const size_t size);
int ReadLMS7002MSPI(const uint32_t *writeData, uint32_t *readData, const size_t size);
int WriteSi5351I2C(const std::string &data);
int ReadSi5351I2C(const size_t numBytes, std::string &data);
int WriteADF4002SPI(const uint32_t *writeData, const size_t size);
int ReadADF4002SPI(const uint32_t *writeData, uint32_t *readData, const size_t size);
unsigned char* PreparePacket(const GenericPacket &pkt, int &length, const eLMS_PROTOCOL protocol);
int ParsePacket(GenericPacket &pkt, const unsigned char* buffer, const int length, const eLMS_PROTOCOL protocol);
std::mutex mControlPortLock;
double _cachedRefClockRate;
};
}
|