Skip to content

Commit

Permalink
Merge pull request #534 from gid9798/cc1101_ext
Browse files Browse the repository at this point in the history
Cc1101 ext
  • Loading branch information
xMasterX authored Jul 10, 2023
2 parents 171fd94 + 5897b82 commit f91a731
Show file tree
Hide file tree
Showing 95 changed files with 4,041 additions and 1,476 deletions.
40 changes: 40 additions & 0 deletions applications/debug/subghz_test/views/subghz_test_carrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct SubGhzTestCarrier {
View* view;
FuriTimer* timer;
SubGhzTestCarrierCallback callback;
// const SubGhzDevice* radio_device;
void* context;
};

Expand Down Expand Up @@ -84,6 +85,7 @@ void subghz_test_carrier_draw(Canvas* canvas, SubGhzTestCarrierModel* model) {
bool subghz_test_carrier_input(InputEvent* event, void* context) {
furi_assert(context);
SubGhzTestCarrier* subghz_test_carrier = context;
// const SubGhzDevice* radio_device = subghz_test_carrier->radio_device;

if(event->key == InputKeyBack || event->type != InputTypeShort) {
return false;
Expand All @@ -94,6 +96,7 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
SubGhzTestCarrierModel * model,
{
furi_hal_subghz_idle();
// subghz_devices_idle(radio_device);

if(event->key == InputKeyLeft) {
if(model->frequency > 0) model->frequency--;
Expand All @@ -114,10 +117,18 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
model->real_frequency =
furi_hal_subghz_set_frequency(subghz_frequencies_testing[model->frequency]);
furi_hal_subghz_set_path(model->path);
// model->real_frequency = subghz_devices_set_frequency(
// radio_device, subghz_frequencies_testing[model->frequency]);

if(model->status == SubGhzTestCarrierModelStatusRx) {
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
furi_hal_subghz_rx();
// furi_hal_gpio_init(
// subghz_devices_get_data_gpio(radio_device),
// GpioModeInput,
// GpioPullNo,
// GpioSpeedLow);
// subghz_devices_set_rx(radio_device);
} else {
furi_hal_gpio_init(
&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
Expand All @@ -127,6 +138,15 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
subghz_test_carrier->callback(
SubGhzTestCarrierEventOnlyRx, subghz_test_carrier->context);
}
// if(!subghz_devices_set_tx(radio_device)) {
// furi_hal_gpio_init(
// subghz_devices_get_data_gpio(radio_device),
// GpioModeInput,
// GpioPullNo,
// GpioSpeedLow);
// subghz_test_carrier->callback(
// SubGhzTestCarrierEventOnlyRx, subghz_test_carrier->context);
// }
}
},
true);
Expand All @@ -137,26 +157,37 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) {
void subghz_test_carrier_enter(void* context) {
furi_assert(context);
SubGhzTestCarrier* subghz_test_carrier = context;
// furi_assert(subghz_test_carrier->radio_device);
// const SubGhzDevice* radio_device = subghz_test_carrier->radio_device;

furi_hal_subghz_reset();
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);

furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);

// subghz_devices_reset(radio_device);
// subghz_devices_load_preset(radio_device, FuriHalSubGhzPresetOok650Async, NULL);

// furi_hal_gpio_init(
// subghz_devices_get_data_gpio(radio_device), GpioModeInput, GpioPullNo, GpioSpeedLow);

with_view_model(
subghz_test_carrier->view,
SubGhzTestCarrierModel * model,
{
model->frequency = subghz_frequencies_433_92_testing; // 433
model->real_frequency =
furi_hal_subghz_set_frequency(subghz_frequencies_testing[model->frequency]);
// model->real_frequency = subghz_devices_set_frequency(
// radio_device, subghz_frequencies_testing[model->frequency]);
model->path = FuriHalSubGhzPathIsolate; // isolate
model->rssi = 0.0f;
model->status = SubGhzTestCarrierModelStatusRx;
},
true);

furi_hal_subghz_rx();
// subghz_devices_set_rx(radio_device);

furi_timer_start(subghz_test_carrier->timer, furi_kernel_get_tick_frequency() / 4);
}
Expand All @@ -169,6 +200,7 @@ void subghz_test_carrier_exit(void* context) {

// Reinitialize IC to default state
furi_hal_subghz_sleep();
// subghz_devices_sleep(subghz_test_carrier->radio_device);
}

void subghz_test_carrier_rssi_timer_callback(void* context) {
Expand All @@ -181,6 +213,7 @@ void subghz_test_carrier_rssi_timer_callback(void* context) {
{
if(model->status == SubGhzTestCarrierModelStatusRx) {
model->rssi = furi_hal_subghz_get_rssi();
// model->rssi = subghz_devices_get_rssi(subghz_test_carrier->radio_device);
}
},
false);
Expand Down Expand Up @@ -216,3 +249,10 @@ View* subghz_test_carrier_get_view(SubGhzTestCarrier* subghz_test_carrier) {
furi_assert(subghz_test_carrier);
return subghz_test_carrier->view;
}

// void subghz_test_carrier_set_radio(
// SubGhzTestCarrier* subghz_test_carrier,
// const SubGhzDevice* radio_device) {
// furi_assert(subghz_test_carrier);
// subghz_test_carrier->radio_device = radio_device;
// }
5 changes: 5 additions & 0 deletions applications/debug/subghz_test/views/subghz_test_carrier.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <gui/view.h>
// #include <lib/subghz/devices/devices.h>

typedef enum {
SubGhzTestCarrierEventOnlyRx,
Expand All @@ -20,3 +21,7 @@ SubGhzTestCarrier* subghz_test_carrier_alloc();
void subghz_test_carrier_free(SubGhzTestCarrier* subghz_test_carrier);

View* subghz_test_carrier_get_view(SubGhzTestCarrier* subghz_test_carrier);

// void subghz_test_carrier_set_radio(
// SubGhzTestCarrier* subghz_test_carrier,
// const SubGhzDevice* radio_device);
11 changes: 8 additions & 3 deletions applications/debug/unit_tests/subghz/subghz_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <lib/subghz/subghz_file_encoder_worker.h>
#include <lib/subghz/protocols/protocol_items.h>
#include <flipper_format/flipper_format_i.h>
#include <lib/subghz/devices/devices.h>
#include <lib/subghz/devices/cc1101_configs.h>

#define TAG "SubGhz TEST"
#define KEYSTORE_DIR_NAME EXT_PATH("subghz/assets/keeloq_mfcodes")
Expand Down Expand Up @@ -49,12 +51,15 @@ static void subghz_test_init(void) {
subghz_environment_set_protocol_registry(
environment_handler, (void*)&subghz_protocol_registry);

subghz_devices_init();

receiver_handler = subghz_receiver_alloc_init(environment_handler);
subghz_receiver_set_filter(receiver_handler, SubGhzProtocolFlag_Decodable);
subghz_receiver_set_rx_callback(receiver_handler, subghz_test_rx_callback, NULL);
}

static void subghz_test_deinit(void) {
subghz_devices_deinit();
subghz_receiver_free(receiver_handler);
subghz_environment_free(environment_handler);
}
Expand All @@ -68,7 +73,7 @@ static bool subghz_decoder_test(const char* path, const char* name_decoder) {

if(decoder) {
file_worker_encoder_handler = subghz_file_encoder_worker_alloc();
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path)) {
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path, NULL)) {
// the worker needs a file in order to open and read part of the file
furi_delay_ms(100);

Expand Down Expand Up @@ -108,7 +113,7 @@ static bool subghz_decode_random_test(const char* path) {
uint32_t test_start = furi_get_tick();

file_worker_encoder_handler = subghz_file_encoder_worker_alloc();
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path)) {
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path, NULL)) {
// the worker needs a file in order to open and read part of the file
furi_delay_ms(100);

Expand Down Expand Up @@ -318,7 +323,7 @@ bool subghz_hal_async_tx_test_run(SubGhzHalAsyncTxTestType type) {
SubGhzHalAsyncTxTest test = {0};
test.type = type;
furi_hal_subghz_reset();
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);
furi_hal_subghz_set_frequency_and_path(433920000);

if(!furi_hal_subghz_start_async_tx(subghz_hal_async_tx_test_yield, &test)) {
Expand Down
6 changes: 6 additions & 0 deletions applications/drivers/application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Placeholder
App(
appid="drivers",
name="Drivers device",
apptype=FlipperAppType.METAPACKAGE,
)
8 changes: 8 additions & 0 deletions applications/drivers/subghz/application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
App(
appid="radio_device_cc1101_ext",
apptype=FlipperAppType.PLUGIN,
targets=["f7"],
entry_point="subghz_device_cc1101_ext_ep",
requires=["subghz"],
fap_libs=["hwdrivers"],
)
Loading

0 comments on commit f91a731

Please sign in to comment.