diff --git a/source_modules/hermes_source/src/hermes.cpp b/source_modules/hermes_source/src/hermes.cpp index eb670d36..71baf5b1 100644 --- a/source_modules/hermes_source/src/hermes.cpp +++ b/source_modules/hermes_source/src/hermes.cpp @@ -20,6 +20,7 @@ namespace hermes { } void Client::start() { + // Start metis stream for (int i = 0; i < HERMES_METIS_REPEAT; i++) { sendMetisControl((MetisControl)(METIS_CTRL_IQ | METIS_CTRL_NO_WD)); } @@ -38,14 +39,14 @@ namespace hermes { void Client::setFrequency(double freq) { this->freq = freq; writeReg(HL_REG_TX1_NCO_FREQ, freq); - autoeFilters(freq); + autoFilters(freq); } void Client::setGain(int gain) { writeReg(HL_REG_RX_LNA, gain | (1 << 6)); } - void Client::autoeFilters(double freq) { + void Client::autoFilters(double freq) { uint8_t filt = (freq >= 3000000.0) ? (1 << 6) : 0; if (freq <= 2000000.0) { @@ -70,6 +71,13 @@ namespace hermes { // Write only if the config actually changed if (filt != lastFilt) { lastFilt = filt; + + spdlog::warn("Setting filters"); + + // Set direction and wait for things to be processed + writeI2C(I2C_PORT_2, 0x20, 0x00, 0x00); + + // Set pins writeI2C(I2C_PORT_2, 0x20, 0x0A, filt); } } @@ -140,6 +148,11 @@ namespace hermes { wdata |= 1 << 23; wdata |= 0x06 << 24; writeReg(HL_REG_I2C_1 + port, wdata); +#ifdef _WIN32 + Sleep(HERMES_I2C_DELAY); +#else + usleep(HERMES_I2C_DELAY*1000); +#endif } void Client::worker() { diff --git a/source_modules/hermes_source/src/hermes.h b/source_modules/hermes_source/src/hermes.h index cba1e213..4d694e34 100644 --- a/source_modules/hermes_source/src/hermes.h +++ b/source_modules/hermes_source/src/hermes.h @@ -11,6 +11,7 @@ #define HERMES_METIS_TIMEOUT 1000 #define HERMES_METIS_SIGNATURE 0xEFFE #define HERMES_HPSDR_USB_SYNC 0x7F +#define HERMES_I2C_DELAY 50 namespace hermes { enum MetisPacketType { @@ -135,7 +136,7 @@ namespace hermes { void setSamplerate(HermesLiteSamplerate samplerate); void setFrequency(double freq); void setGain(int gain); - void autoeFilters(double freq); + void autoFilters(double freq); dsp::stream out;