Add 1kHz test tone for M17 deviation setting.

m17
Rob Riggs 2021-07-24 15:53:55 -05:00
rodzic f37e2cb65f
commit 06b0b5e919
6 zmienionych plików z 47 dodań i 6 usunięć

Wyświetl plik

@ -133,6 +133,8 @@ struct AFSKModulator : Modulator
}
}
void tone(uint16_t freq) override {}
void fill(uint16_t* buffer, bool bit)
{
HAL_IWDG_Refresh(&hiwdg);
@ -155,7 +157,7 @@ struct AFSKModulator : Modulator
}
}
if (s < 0 or s > 4095) {
DEBUG("DAC inversion (%d)", s);
TNC_DEBUG("DAC inversion (%d)", s);
}
*buffer = uint16_t(s);
++buffer;

Wyświetl plik

@ -104,6 +104,7 @@ void AFSKTestTone::fill() const
case AFSKTestTone::State::SPACE:
if (kiss::settings().modem_type == kiss::Hardware::ModemType::M17)
{
getModulator().tone(1);
getModulator().send(0x22);
}
else

Wyświetl plik

@ -108,6 +108,8 @@ struct Fsk9600Modulator : Modulator
}
}
void tone(uint16_t freq) override {}
// DAC DMA interrupt functions.
void fill_first(uint8_t bit) override

Wyświetl plik

@ -28,14 +28,12 @@ void log_(int level, const char *fmt, ...) __attribute__((format(printf, 2, 3)))
#define LOG(level, ...) if(level >= KISS_LOG_LEVEL) log_(level, __VA_ARGS__);
#define DEBUG(...) LOG(0, __VA_ARGS__)
#define TNC_DEBUG(...) LOG(0, __VA_ARGS__)
#define INFO(...) LOG(1, __VA_ARGS__)
#define WARN(...) LOG(2, __VA_ARGS__)
#define ERROR(...) LOG(3, __VA_ARGS__)
#define SEVERE(...) LOG(4, __VA_ARGS__)
#else
#define DEBUG(...)
#define TNC_DEBUG(...)
#define INFO(...)
#define WARN(...)

Wyświetl plik

@ -26,7 +26,7 @@ struct M17Modulator : Modulator
// Six buffers per M17 frame, or 12 half-buffer interrupts.
static constexpr uint8_t UPSAMPLE = 10;
static constexpr uint32_t BLOCKSIZE = 4;
static constexpr uint32_t STATE_SIZE = (m17::FILTER_TAP_NUM_9 / UPSAMPLE) + BLOCKSIZE - 1;
static constexpr uint32_t STATE_SIZE = (m17::FILTER_TAP_NUM_15 / UPSAMPLE) + BLOCKSIZE - 1;
static constexpr int16_t DAC_BUFFER_LEN = 80; // 8 symbols, 16 bits, 2 bytes.
static constexpr int16_t TRANSFER_LEN = DAC_BUFFER_LEN / 2; // 4 symbols, 8 bits, 1 byte.
static constexpr uint16_t VREF = 4095;
@ -43,13 +43,14 @@ struct M17Modulator : Modulator
volatile uint16_t stop_count = 0; // Flush the RRC matched filter.
State state{State::STOPPED};
float tmp[TRANSFER_LEN];
bool send_tone = false;
M17Modulator(osMessageQId queue, PTT* ptt)
: dacOutputQueueHandle_(queue), ptt_(ptt)
{
arm_fir_interpolate_init_f32(
&fir_interpolator, UPSAMPLE, m17::FILTER_TAP_NUM_9,
(float32_t*) m17::rrc_taps_f9.data(), fir_state.data(), BLOCKSIZE);
&fir_interpolator, UPSAMPLE, m17::FILTER_TAP_NUM_15,
(float32_t*) m17::rrc_taps_f15.data(), fir_state.data(), BLOCKSIZE);
}
~M17Modulator() override {}
@ -127,6 +128,20 @@ struct M17Modulator : Modulator
}
}
constexpr std::array<float, 48> make_1000hz_tone()
{
std::array<float, 48> result;
for (size_t i = 0; i != result.size(); ++i) {
result[i] = std::sin(M_PI * i * 2.0 / result.size()) * 3;
}
return result;
}
void tone(uint16_t) override
{
send_tone = true;
}
// DAC DMA interrupt functions.
[[gnu::noinline]]
void fill_first(uint8_t bits) override
@ -218,6 +233,7 @@ struct M17Modulator : Modulator
void abort() override
{
state = State::STOPPED;
send_tone = false;
stop_conversion();
ptt_->off();
#if defined(KISS_LOGGING) && !defined(NUCLEOTNC)
@ -295,9 +311,28 @@ private:
}
}
void fill_tone(int16_t* buffer)
{
static uint8_t pos = 0;
static const auto Hz1000 = make_1000hz_tone();
int16_t polarity = kiss::settings().tx_rev_polarity() ? -1 : 1;
for (size_t i = 0; i != TRANSFER_LEN; ++i) {
buffer[i] = adjust_level(Hz1000[pos++] * polarity);
if (pos == Hz1000.size()) pos = 0;
}
}
[[gnu::noinline]]
void fill(int16_t* buffer, uint8_t bits)
{
if (send_tone)
{
fill_tone(buffer);
return;
}
int16_t polarity = kiss::settings().tx_rev_polarity() ? -1 : 1;
for (size_t i = 0; i != 4; ++i)
@ -333,6 +368,7 @@ private:
[[gnu::noinline]]
void fill_empty(int16_t* buffer)
{
send_tone = false;
for (size_t i = 0; i != TRANSFER_LEN; ++i)
{
buffer[i] = 2048;

Wyświetl plik

@ -59,6 +59,8 @@ struct Modulator
*/
virtual void send(uint8_t symbol) = 0;
virtual void tone(uint16_t freq) = 0;
/// The next three functions are called by the DAC DMA interrupt handler.
/**