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 destructor */
virtual ~Device() { } virtual ~Device() { }
/** Type conversions if necessary */
static short convertHostDeviceShort(short value);
static short convertDeviceHostShort(short value);
}; };
#endif // _DEVICE_H_ #endif // _DEVICE_H_

View File

@ -704,17 +704,3 @@ Device *Device::make(double sampleRate, bool skipRx)
{ {
return new UHDDevice(sampleRate, 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

@ -416,6 +416,13 @@ int USRPDevice::readSamples(short *buf, int len, bool *overrun,
timeStart = timestamp + len; timeStart = timestamp + len;
if (readBuf!=NULL) delete[] readBuf; 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; return len;
#else #else
@ -461,6 +468,10 @@ int USRPDevice::writeSamples(short *buf, int len, bool *underrun,
#ifndef SWLOOPBACK #ifndef SWLOOPBACK
if (!m_uTx) return 0; if (!m_uTx) return 0;
for (int i = 0; i < len*2; i++) {
buf[i] = host_to_usrp_short(buf[i]);
}
int numWritten = 0; int numWritten = 0;
unsigned isStart = 1; unsigned isStart = 1;
unsigned RSSI = 0; unsigned RSSI = 0;
@ -550,15 +561,3 @@ Device *Device::make(double desiredSampleRate, bool skipRx)
{ {
return new USRPDevice(desiredSampleRate, 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(); signalVector::iterator itr = wVector.begin();
short *shortItr = retVector; short *shortItr = retVector;
while (itr < wVector.end()) { while (itr < wVector.end()) {
*shortItr++ = usrp->convertHostDeviceShort(itr->real()); *shortItr++ = itr->real();
*shortItr++ = usrp->convertHostDeviceShort(itr->imag()); *shortItr++ = itr->imag();
itr++; itr++;
} }
@ -98,24 +98,8 @@ signalVector *RadioInterface::unUSRPifyVector(short *shortVector, int numSamples
signalVector::iterator itr = newVector->begin(); signalVector::iterator itr = newVector->begin();
short *shortItr = shortVector; 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()) { while (itr < newVector->end()) {
*itr++ = Complex<float>(usrp->convertDeviceHostShort(*(shortItr+FLIP_IQ)), *itr++ = Complex<float>(*shortItr, *(shortItr+1));
usrp->convertDeviceHostShort(*(shortItr+1-FLIP_IQ)));
shortItr += 2; shortItr += 2;
} }