laforge
/
openbts-osmo
Archived
1
0
Fork 0

Transceiver: move I/Q swap and byteorder to behind device interface

The non-UHD implementation tunes the DDC to output an inverted
spectrum that requires swapping on the host. Push I/Q and byte
swapping into the device implementation and strip the related
bits out of the remaining transceiver code.

This also moves the Transceiver closer to the Transcever52M
version.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
This commit is contained in:
Thomas Tsou 2011-01-11 20:16:53 -05:00
parent f1ec79c540
commit 753118031e
4 changed files with 15 additions and 50 deletions

View File

@ -85,10 +85,6 @@ public:
/** Virtual destructor */
virtual ~Device() { }
/** Type conversions if necessary */
static short convertHostDeviceShort(short value);
static short convertDeviceHostShort(short value);
};
#endif // _DEVICE_H_

View File

@ -704,17 +704,3 @@ Device *Device::make(double sampleRate, bool skipRx)
{
return new UHDDevice(sampleRate, skipRx);
}
short Device::convertHostDeviceShort(short value)
{
// Type conversion handled internally by UHD
return value;
}
short Device::convertDeviceHostShort(short value)
{
// Type conversion handled internally by UHD
return value;
}

View File

@ -415,6 +415,13 @@ int USRPDevice::readSamples(short *buf, int len, bool *overrun,
dataStart = (bufStart + len) % (currDataSize/2);
timeStart = timestamp + len;
if (readBuf!=NULL) delete[] readBuf;
// do IQ swap here
for (int i = 0; i < len; i++) {
short tmp = usrp_to_host_short(buf[2*i]);
buf[2*i] = usrp_to_host_short(buf[2*i+1]);
buf[2*i+1] = tmp;
}
return len;
@ -460,7 +467,11 @@ int USRPDevice::writeSamples(short *buf, int len, bool *underrun,
{
#ifndef SWLOOPBACK
if (!m_uTx) return 0;
for (int i = 0; i < len*2; i++) {
buf[i] = host_to_usrp_short(buf[i]);
}
int numWritten = 0;
unsigned isStart = 1;
unsigned RSSI = 0;
@ -550,15 +561,3 @@ Device *Device::make(double desiredSampleRate, bool skipRx)
{
return new USRPDevice(desiredSampleRate, skipRx);
}
short Device::convertHostDeviceShort(short value)
{
return host_to_usrp_short(value);
}
short Device::convertDeviceHostShort(short value)
{
return usrp_to_host_short(value);
}

View File

@ -80,8 +80,8 @@ short *RadioInterface::USRPifyVector(signalVector &wVector)
signalVector::iterator itr = wVector.begin();
short *shortItr = retVector;
while (itr < wVector.end()) {
*shortItr++ = usrp->convertHostDeviceShort(itr->real());
*shortItr++ = usrp->convertHostDeviceShort(itr->imag());
*shortItr++ = itr->real();
*shortItr++ = itr->imag();
itr++;
}
@ -98,24 +98,8 @@ signalVector *RadioInterface::unUSRPifyVector(short *shortVector, int numSamples
signalVector::iterator itr = newVector->begin();
short *shortItr = shortVector;
// This is hideous.
// UHD & !SWLOOPBACK: FLIP_IQ = 0
// UHD & SWLOOPBACK: FLIP_IQ = 0
// USRP1 & !SWLOOPBACK: FLIP_IQ = 1
// USRP1 & SWLOOPBACK: FLIP_IQ = 0
#ifdef USE_UHD
#define FLIP_IQ 0
#else
#ifndef SWLOOPBACK
#define FLIP_IQ 1
#else
#define FLIP_IQ 0
#endif
#endif
while (itr < newVector->end()) {
*itr++ = Complex<float>(usrp->convertDeviceHostShort(*(shortItr+FLIP_IQ)),
usrp->convertDeviceHostShort(*(shortItr+1-FLIP_IQ)));
*itr++ = Complex<float>(*shortItr, *(shortItr+1));
shortItr += 2;
}