Skip to content

Commit

Permalink
SubGhz: fix frequency determination in a frequency analyzer (flipperd…
Browse files Browse the repository at this point in the history
  • Loading branch information
Skorpionm authored Oct 13, 2021
1 parent 0644478 commit 6342860
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions applications/subghz/helpers/subghz_frequency_analyzer_worker.c
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 6342860

Please sign in to comment.