-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
soapy: Use the new IOCTL call on enumeration
soapy: Si5351: Move device ID/revision support checks to constructor instead of init function soapy: Si5351: Normalize phase to 0-360 instead of throwing an error soapy: Si5351: Add method to mask/unmask a clock enable from the OEb pin soapy: Si5351: Add IRQ config soapy: Set external clock output independent of OEb pin soapy: Add AuxMCU base class soapy: Add PMC MCU communication library barebones soapy: Add LT7182S support library soapy: Add 8V97003 mmWave synth support library soapy: Add preliminary ExpansionCard base class soapy: AXIIIC: count is uint8_t, limited by the controller dynamic mode, for now soapy: Misc fixes Signed-off-by: João Silva <jgc3silva@gmail.com>
- Loading branch information
Showing
18 changed files
with
4,374 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#include "AuxMCU.hpp" | ||
|
||
uint8_t AuxMCU::calcChecksum(uint8_t *data, uint8_t count) | ||
{ | ||
uint8_t cs = this->iic.addr; | ||
|
||
for(uint16_t i = 0; i < count; i++) | ||
cs += data[i]; | ||
|
||
return (0xFF - cs) + 1; | ||
} | ||
|
||
void AuxMCU::readReg(uint8_t reg, uint8_t *dst, uint8_t count, bool check) | ||
{ | ||
if(this->iic.controller == nullptr) | ||
throw std::runtime_error("AuxMCU: IIC not initialized"); | ||
|
||
if(!count) | ||
return; | ||
|
||
if(count > 256 - 2) | ||
throw std::runtime_error("AuxMCU: Read too long"); | ||
|
||
if(dst == nullptr) | ||
throw std::runtime_error("AuxMCU: Invalid destination buffer"); | ||
|
||
std::lock_guard<std::mutex> lock(this->mutex); | ||
|
||
uint8_t buf[256]; | ||
|
||
buf[0] = reg; | ||
buf[1] = 0xFF; | ||
buf[2] = count; | ||
buf[3] = this->calcChecksum(buf, 3); | ||
|
||
this->iic.controller->lock(); // Lock the I2C bus so the next two transactions are not interrupted | ||
|
||
this->iic.controller->write(this->iic.addr, buf, 4, AXIIIC::Stop::RESTART); | ||
this->iic.controller->read(this->iic.addr, buf, count + 1, AXIIIC::Stop::STOP); | ||
|
||
this->iic.controller->unlock(); // Unlock the I2C bus | ||
|
||
if(check && !this->checkChecksum(buf, count + 1)) | ||
throw std::runtime_error("AuxMCU: Checksum mismatch"); | ||
|
||
for(uint8_t i = 0; i < count; i++) | ||
dst[i] = buf[i]; | ||
} | ||
void AuxMCU::writeReg(uint8_t reg, uint8_t *src, uint8_t count) | ||
{ | ||
if(this->iic.controller == nullptr) | ||
throw std::runtime_error("AuxMCU: IIC not initialized"); | ||
|
||
if(!count) | ||
return; | ||
|
||
if(src == nullptr) | ||
throw std::runtime_error("AuxMCU: Invalid source buffer"); | ||
|
||
if(count > 256 - 3) | ||
throw std::runtime_error("AuxMCU: Data too long"); | ||
|
||
std::lock_guard<std::mutex> lock(this->mutex); | ||
|
||
uint8_t buf[256]; | ||
|
||
buf[0] = reg; | ||
buf[1] = count; | ||
|
||
for(uint8_t i = 0; i < count; i++) | ||
buf[i + 2] = src[i]; | ||
|
||
buf[count + 2] = this->calcChecksum(buf, count + 2); | ||
|
||
// No need to lock the I2C bus here, since I2C transactions are guaranteed to be atomic | ||
this->iic.controller->write(this->iic.addr, buf, count + 3, AXIIIC::Stop::STOP); | ||
} | ||
|
||
AuxMCU::AuxMCU(AuxMCU::IICConfig iic) | ||
{ | ||
this->iic = iic; | ||
|
||
if(this->iic.controller == nullptr) | ||
throw std::runtime_error("AuxMCU: IIC not initialized"); | ||
|
||
if(!this->iic.controller->scan(this->iic.addr)) | ||
throw std::runtime_error("AuxMCU: Device not found on IIC bus"); | ||
} | ||
AuxMCU::~AuxMCU() | ||
{ | ||
// Nothing to do here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#include "ExpansionCard.hpp" | ||
|
||
ExpansionCard::ExpansionCard(AXIIIC *iic_controller) | ||
{ | ||
this->iic_controller = iic_controller; | ||
} | ||
ExpansionCard::~ExpansionCard() | ||
{ | ||
// Nothing to do here | ||
} | ||
|
||
SoapySDR::Kwargs ExpansionCard::getHardwareInfo() | ||
{ | ||
return SoapySDR::Kwargs(); | ||
} | ||
|
||
size_t ExpansionCard::getNumChannels(const int direction) | ||
{ | ||
return 0; | ||
} | ||
SoapySDR::Kwargs ExpansionCard::getChannelInfo(const int direction, const size_t channel) | ||
{ | ||
return SoapySDR::Kwargs(); | ||
} | ||
bool ExpansionCard::getFullDuplex(const int direction, const size_t channel) | ||
{ | ||
return false; | ||
} | ||
|
||
std::vector<std::string> ExpansionCard::listAntennas(const int direction, const size_t channel) | ||
{ | ||
return std::vector<std::string>(); | ||
} | ||
void ExpansionCard::setAntenna(const int direction, const size_t channel, const std::string &name) | ||
{ | ||
// Do nothing | ||
} | ||
std::string ExpansionCard::getAntenna(const int direction, const size_t channel) | ||
{ | ||
return ""; | ||
} | ||
|
||
std::vector<std::string> ExpansionCard::listGains(const int direction, const size_t channel) | ||
{ | ||
return std::vector<std::string>(); | ||
} | ||
bool ExpansionCard::hasGainMode(const int direction, const size_t channel) | ||
{ | ||
return false; | ||
} | ||
void ExpansionCard::setGainMode(const int direction, const size_t channel, const bool automatic) | ||
{ | ||
// Do nothing | ||
} | ||
bool ExpansionCard::getGainMode(const int direction, const size_t channel) | ||
{ | ||
return false; | ||
} | ||
void ExpansionCard::setGain(const int direction, const size_t channel, const double value) | ||
{ | ||
// Do nothing | ||
} | ||
void ExpansionCard::setGain(const int direction, const size_t channel, const std::string &name, const double value) | ||
{ | ||
// Do nothing | ||
} | ||
double ExpansionCard::getGain(const int direction, const size_t channel) | ||
{ | ||
return 0.0; | ||
} | ||
double ExpansionCard::getGain(const int direction, const size_t channel, const std::string &name) | ||
{ | ||
return 0.0; | ||
} | ||
SoapySDR::Range ExpansionCard::getGainRange(const int direction, const size_t channel) | ||
{ | ||
return SoapySDR::Range(); | ||
} | ||
SoapySDR::Range ExpansionCard::getGainRange(const int direction, const size_t channel, const std::string &name) | ||
{ | ||
return SoapySDR::Range(); | ||
} | ||
|
||
void ExpansionCard::setFrequency(const int direction, const size_t channel, const double frequency) | ||
{ | ||
// Do nothing | ||
} | ||
void ExpansionCard::setFrequency(const int direction, const size_t channel, const std::string &name, const double frequency) | ||
{ | ||
// Do nothing | ||
} | ||
double ExpansionCard::getFrequency(const int direction, const size_t channel) | ||
{ | ||
return 0.0; | ||
} | ||
double ExpansionCard::getFrequency(const int direction, const size_t channel, const std::string &name) | ||
{ | ||
return 0.0; | ||
} | ||
std::vector<std::string> ExpansionCard::listFrequencies(const int direction, const size_t channel) | ||
{ | ||
return std::vector<std::string>(); | ||
} | ||
SoapySDR::RangeList ExpansionCard::getFrequencyRange(const int direction, const size_t channel) | ||
{ | ||
return SoapySDR::RangeList(); | ||
} | ||
SoapySDR::RangeList ExpansionCard::getFrequencyRange(const int direction, const size_t channel, const std::string &name) | ||
{ | ||
return SoapySDR::RangeList(); | ||
} |
Oops, something went wrong.