aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/x300
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2016-08-15 11:21:57 -0700
committerMartin Braun <martin.braun@ettus.com>2016-09-02 11:10:46 -0700
commit7ea624b179cfb2cd6204be4dc128ba7ef07f4546 (patch)
tree4b2e34bea964b9e2ff2d1429301d70171f49c90c /host/lib/usrp/x300
parentb229a1972c421c90420363ce1f93be91cc9bd2aa (diff)
downloaduhd-7ea624b179cfb2cd6204be4dc128ba7ef07f4546.tar.gz
uhd-7ea624b179cfb2cd6204be4dc128ba7ef07f4546.tar.bz2
uhd-7ea624b179cfb2cd6204be4dc128ba7ef07f4546.zip
X300: GPSDO fixes
- Optimize writes so full 32-bit words are written at a time - Simplify UART so it does not strip or add characters
Diffstat (limited to 'host/lib/usrp/x300')
-rw-r--r--host/lib/usrp/x300/x300_fw_uart.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/host/lib/usrp/x300/x300_fw_uart.cpp b/host/lib/usrp/x300/x300_fw_uart.cpp
index 86141ca9a..7f60e26fc 100644
--- a/host/lib/usrp/x300/x300_fw_uart.cpp
+++ b/host/lib/usrp/x300/x300_fw_uart.cpp
@@ -30,28 +30,36 @@ using namespace uhd;
struct x300_uart_iface : uart_iface
{
x300_uart_iface(wb_iface::sptr iface):
- rxoffset(0), txoffset(0), txword32(0), rxpool(0), txpool(0), poolsize(0)
+ _iface(iface),
+ rxoffset(0),
+ txword32(0),
+ _last_device_rxoffset(0)
{
- _iface = iface;
- rxoffset = _iface->peek32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_UART_RX_INDEX));
txoffset = _iface->peek32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_UART_TX_INDEX));
rxpool = _iface->peek32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_UART_RX_ADDR));
txpool = _iface->peek32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_UART_TX_ADDR));
poolsize = _iface->peek32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_UART_WORDS32));
_rxcache.resize(poolsize);
- _last_device_rxoffset = rxoffset;
//this->write_uart("HELLO UART\n");
//this->read_uart(0.1);
}
void putchar(const char ch)
{
- txoffset = (txoffset + 1) % (poolsize*4);
const int shift = ((txoffset%4) * 8);
if (shift == 0) txword32 = 0;
txword32 |= boost::uint32_t(ch) << shift;
- _iface->poke32(SR_ADDR(txpool, txoffset/4), txword32);
- _iface->poke32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_UART_TX_INDEX), txoffset);
+ // Write out full 32 bit words or whatever we have if end of string
+ if (txoffset % 4 == 3 or ch == '\n')
+ {
+ _iface->poke32(SR_ADDR(txpool, txoffset/4), txword32);
+ }
+ txoffset = (txoffset + 1) % (poolsize*4);
+ if (ch == '\n')
+ {
+ // Tell the X300 to write the string
+ _iface->poke32(SR_ADDR(X300_FW_SHMEM_BASE, X300_FW_SHMEM_UART_TX_INDEX), txoffset);
+ }
}
void write_uart(const std::string &buff)
@@ -59,7 +67,6 @@ struct x300_uart_iface : uart_iface
boost::mutex::scoped_lock(_write_mutex);
BOOST_FOREACH(const char ch, buff)
{
- if (ch == '\n') this->putchar('\r');
this->putchar(ch);
}
}
@@ -128,22 +135,13 @@ struct x300_uart_iface : uart_iface
// Get available characters
for (int ch = this->getchar(); ch != -1; ch = this->getchar())
{
- // skip carriage returns
- if (ch == '\r')
- continue;
-
- // avoid returning empty strings
- if (ch == '\n' and _rxbuff.empty())
- continue;
-
// store character to buffer
- _rxbuff += std::string(1, (char)ch);
+ _rxbuff.append(1, ch);
// newline found - return string
if (ch == '\n')
{
- buff = _rxbuff;
- _rxbuff.clear();
+ buff.swap(_rxbuff);
return buff;
}
}