SubGhz: fix frequency determination in a frequency analyzer (#762)

This commit is contained in:
Skorpionm 2021-10-13 23:35:33 +04:00 committed by GitHub
parent 06444789bb
commit 63428609b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,28 @@
#include "subghz_frequency_analyzer_worker.h"
#include <lib/drivers/cc1101_regs.h>
#include <furi.h>
#include "../subghz_i.h"
static const uint8_t subghz_preset_ook_58khz[][2] = {
{CC1101_FIFOTHR, 0x47}, // The only important bit is ADC_RETENTION, FIFO Tx=33 Rx=32
{CC1101_MDMCFG4, 0xF5}, // Rx BW filter is 58.035714kHz
{CC1101_TEST2, 0x81}, // FIFOTHR ADC_RETENTION=1 matched value
{CC1101_TEST1, 0x35}, // FIFOTHR ADC_RETENTION=1 matched value
/* End */
{0, 0},
};
static const uint8_t subghz_preset_ook_650khz[][2] = {
{CC1101_FIFOTHR, 0x07}, // The only important bit is ADC_RETENTION
{CC1101_MDMCFG4, 0x17}, // Rx BW filter is 650.000kHz
{CC1101_TEST2, 0x88},
{CC1101_TEST1, 0x31},
/* End */
{0, 0},
};
struct SubGhzFrequencyAnalyzerWorker {
FuriThread* thread;
@ -56,6 +75,8 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
while(instance->worker_running) {
osDelay(10);
frequency_rssi.rssi = -127.0f;
furi_hal_subghz_idle();
furi_hal_subghz_load_registers(subghz_preset_ook_650khz);
for(size_t i = 0; i < subghz_frequencies_count; i++) {
if(furi_hal_subghz_is_frequency_valid(subghz_frequencies[i])) {
furi_hal_subghz_idle();
@ -74,6 +95,9 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
// -0.5 ... 433.92 ... +0.5
frequency_start = frequency_rssi.frequency - 250000;
//step 10KHz
frequency_rssi.rssi = -127.0;
furi_hal_subghz_idle();
furi_hal_subghz_load_registers(subghz_preset_ook_58khz);
for(uint32_t i = frequency_start; i < frequency_start + 500000; i += 10000) {
if(furi_hal_subghz_is_frequency_valid(i)) {
furi_hal_subghz_idle();