diff options
author | Mark Meserve <mark.meserve@ni.com> | 2017-09-27 17:15:54 -0500 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:04:01 -0800 |
commit | f58a4f20c54dea2cc12e2912c43a8cda597b345c (patch) | |
tree | 3f0e73b7eb79716b50c76fd5e4c46842a7b26be0 /mpm/lib/mykonos | |
parent | 64c5bdbc920fa45ef206c73b0d430087015760f1 (diff) | |
download | uhd-f58a4f20c54dea2cc12e2912c43a8cda597b345c.tar.gz uhd-f58a4f20c54dea2cc12e2912c43a8cda597b345c.tar.bz2 uhd-f58a4f20c54dea2cc12e2912c43a8cda597b345c.zip |
ad937x: address TODOs in adi_ctrl
change error outputs
add comments to some functions
Diffstat (limited to 'mpm/lib/mykonos')
-rw-r--r-- | mpm/lib/mykonos/adi_ctrl.cpp | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/mpm/lib/mykonos/adi_ctrl.cpp b/mpm/lib/mykonos/adi_ctrl.cpp index ac83e2a56..e026466de 100644 --- a/mpm/lib/mykonos/adi_ctrl.cpp +++ b/mpm/lib/mykonos/adi_ctrl.cpp @@ -23,6 +23,7 @@ #include <iostream> #include <chrono> #include <thread> +#include <sstream> ad9371_spiSettings_t::ad9371_spiSettings_t( mpm::types::regs_iface* spi_iface_ @@ -86,7 +87,6 @@ commonErr_t CMB_setSPIChannel(uint16_t chipSelectIndex) commonErr_t CMB_SPIWriteByte(spiSettings_t *spiSettings, uint16_t addr, uint8_t data) { if (spiSettings == nullptr || spiSettings->MSBFirst == 0) { - // TODO: crash and burn for these errors? return COMMONERR_FAILED; } @@ -95,11 +95,19 @@ commonErr_t CMB_SPIWriteByte(spiSettings_t *spiSettings, uint16_t addr, uint8_t spi->spi_iface->poke8(addr, data); return COMMONERR_OK; } catch (const std::exception &e) { - std::cout << "AAAAAAAAAAAAH" << std::endl; + // TODO: spit out a reasonable error here (that will survive the C API transition) + std::stringstream ss; + ss << "Error in CMB_SPIWriteByte: " << e.what(); + CMB_writeToLog( + ADIHAL_LOG_ERROR, + spiSettings->chipSelectIndex, + ad9371_spi_errors_t::SPI_WRITE_ERROR, + ss.str().c_str()); } return COMMONERR_FAILED; } +// multi SPI byte write function (address, data pairs) commonErr_t CMB_SPIWriteBytes(spiSettings_t *spiSettings, uint16_t *addr, uint8_t *data, uint32_t count) { if (spiSettings == nullptr || @@ -107,7 +115,6 @@ commonErr_t CMB_SPIWriteBytes(spiSettings_t *spiSettings, uint16_t *addr, uint8_ data == nullptr || spiSettings->MSBFirst == 0) { - // TODO: crash and burn for these errors? return COMMONERR_FAILED; } @@ -121,7 +128,14 @@ commonErr_t CMB_SPIWriteBytes(spiSettings_t *spiSettings, uint16_t *addr, uint8_ } return COMMONERR_OK; } catch (const std::exception &e) { - std::cout << "AAAAAAAAAAAAH" << std::endl; + // TODO: spit out a reasonable error here (that will survive the C API transition) + std::stringstream ss; + ss << "Error in CMB_SPIWriteBytes: " << e.what(); + CMB_writeToLog( + ADIHAL_LOG_ERROR, + spiSettings->chipSelectIndex, + ad9371_spi_errors_t::SPI_WRITE_ERROR, + ss.str().c_str()); } return COMMONERR_FAILED; } @@ -141,8 +155,14 @@ commonErr_t CMB_SPIReadByte (spiSettings_t *spiSettings, uint16_t addr, uint8_t *readdata = spi->spi_iface->peek8(addr); return COMMONERR_OK; } catch (const std::exception &e) { - std::cout << "AAAAAAAAAAAAH READ" << std::endl; - // ... error handling ... + // TODO: spit out a reasonable error here (that will survive the C API transition) + std::stringstream ss; + ss << "Error in CMB_SPIReadByte: " << e.what(); + CMB_writeToLog( + ADIHAL_LOG_ERROR, + spiSettings->chipSelectIndex, + ad9371_spi_errors_t::SPI_READ_ERROR, + ss.str().c_str()); } return COMMONERR_FAILED; } @@ -161,8 +181,14 @@ commonErr_t CMB_SPIWriteField( spi->spi_iface->poke8(addr, new_value); return COMMONERR_OK; } catch (const std::exception &e) { - std::cout << "AAAAAAAAAAAAH WRITE FIELD" << std::endl; - // ... error handling ... + // TODO: spit out a reasonable error here (that will survive the C API transition) + std::stringstream ss; + ss << "Error in CMB_SPIWriteField: " << e.what(); + CMB_writeToLog( + ADIHAL_LOG_ERROR, + spiSettings->chipSelectIndex, + ad9371_spi_errors_t::SPI_WRITE_ERROR, + ss.str().c_str()); } return COMMONERR_FAILED; } @@ -181,8 +207,14 @@ commonErr_t CMB_SPIReadField( *field_val = static_cast<uint8_t>((value & mask) >> start_bit); return COMMONERR_OK; } catch (const std::exception &e) { - std::cout << "AAAAAAAAAAAAH READ FIELD" << std::endl; - /* ... error handling ... */ + // TODO: spit out a reasonable error here (that will survive the C API transition) + std::stringstream ss; + ss << "Error in CMB_SPIReadField: " << e.what(); + CMB_writeToLog( + ADIHAL_LOG_ERROR, + spiSettings->chipSelectIndex, + ad9371_spi_errors_t::SPI_READ_ERROR, + ss.str().c_str()); } return COMMONERR_FAILED; } @@ -241,6 +273,8 @@ commonErr_t CMB_closeLog(void) commonErr_t CMB_writeToLog(ADI_LOGLEVEL level, uint8_t deviceIndex, uint32_t errorCode, const char *comment) { + // TODO: send to logging API + // TODO: filter log messages based on level std::cout << "[CMB_writeToLog] level==" << level << " errorCode==" << errorCode << " " << comment; return COMMONERR_OK; } |