Skip to content

Commit

Permalink
Fix M17 RX reverse polarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobilinkd committed Oct 26, 2021
1 parent 6cdc8f8 commit 1f3925a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions TNC/KissHardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ int powerOffViaUSB(void)
namespace mobilinkd { namespace tnc { namespace kiss {

#if defined(NUCLEOTNC)
const char FIRMWARE_VERSION[] = "2.4.0";
const char FIRMWARE_VERSION[] = "2.4.1";
const char HARDWARE_VERSION[] = "Mobilinkd NucleoTNC";
#elif defined(STM32L433xx)
const char FIRMWARE_VERSION[] = "2.4.0";
const char FIRMWARE_VERSION[] = "2.4.1";
const char HARDWARE_VERSION[] = "Mobilinkd TNC3 2.1.1";
#elif defined(STM32L4P5xx)
const char FIRMWARE_VERSION[] = "2.4.0";
const char FIRMWARE_VERSION[] = "2.4.1";
const char HARDWARE_VERSION[] = "Mobilinkd TNC3+ Rev A";
#endif
Hardware& settings()
Expand Down
10 changes: 4 additions & 6 deletions TNC/M17Demodulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace mobilinkd { namespace tnc {
//m17::Indicator dcd_indicator{GPIOA, GPIO_PIN_2};
//m17::Indicator str_indicator{GPIOA, GPIO_PIN_7};

static float scale = 1.f / 2560.f;

void M17Demodulator::start()
{
SysClock72();
Expand All @@ -29,6 +31,7 @@ void M17Demodulator::start()
demod_filter.init(m17::rrc_taps_f15);
passall(kiss::settings().options & KISS_OPTION_PASSALL);
polarity = kiss::settings().rx_rev_polarity() ? -1 : 1;
scale = 1.f / 2560.f * polarity;
audio::virtual_ground = (VREF + 1) / 2;

hadc1.Init.OversamplingMode = ENABLE;
Expand Down Expand Up @@ -57,7 +60,7 @@ void M17Demodulator::update_values(uint8_t index)
{
correlator.apply([this,index](float t){dev.sample(t);}, index);
dev.update();
idev = dev.idev() * polarity;
idev = dev.idev();
sync_sample_index = index;
}

Expand Down Expand Up @@ -87,9 +90,6 @@ void M17Demodulator::dcd_off()

void M17Demodulator::initialize(const q15_t* input)
{

static constexpr float scale = 1.f / 2560.f;

for (size_t i = 0; i != ADC_BLOCK_SIZE; i++) {
demod_buffer[i] = float(input[i]) * scale;
}
Expand Down Expand Up @@ -451,8 +451,6 @@ hdlc::IoFrame* M17Demodulator::operator()(const q15_t* input)
// Do adc_micro_adjustment() here?
// adc_micro_adjustment();

static constexpr float scale = 1.f / 2560.f;

for (size_t i = 0; i != ADC_BLOCK_SIZE; i++) {
demod_buffer[i] = float(input[i]) * scale;
}
Expand Down

0 comments on commit 1f3925a

Please sign in to comment.