Move amped code

This commit is contained in:
Sil333033
2023-08-02 20:23:55 +02:00
parent 02db8d4e7d
commit 070fb17485
5 changed files with 62 additions and 63 deletions
+6 -47
View File
@@ -12,10 +12,6 @@ void subghz_devices_init() {
void subghz_devices_deinit(void) {
furi_check(subghz_device_registry_is_valid());
subghz_device_registry_deinit();
if(furi_hal_subghz_get_ext_power_amp()) {
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
}
}
const SubGhzDevice* subghz_devices_get_by_name(const char* device_name) {
@@ -36,24 +32,13 @@ bool subghz_devices_begin(const SubGhzDevice* device) {
bool ret = false;
furi_assert(device);
if(device->interconnect->begin) {
// TODO: Remake this check and move this code
if(strcmp("cc1101_ext", device->name) == 0) {
SubGhzLastSettings* last_settings = subghz_last_settings_alloc();
subghz_last_settings_load(last_settings, 0);
SubGhzDeviceConf conf = {
.ver = 1,
.extended_range = false, // TODO
.power_amp = furi_hal_subghz_get_ext_power_amp(),
};
if(last_settings->external_module_power_amp) {
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
furi_hal_subghz_set_ext_power_amp(true);
}
subghz_last_settings_free(last_settings);
if(furi_hal_subghz_get_ext_power_amp()) {
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
}
}
ret = device->interconnect->begin();
ret = device->interconnect->begin(&conf);
}
return ret;
}
@@ -61,12 +46,6 @@ bool subghz_devices_begin(const SubGhzDevice* device) {
void subghz_devices_end(const SubGhzDevice* device) {
furi_assert(device);
if(device->interconnect->end) {
// TODO: Remake this check and move this code
if(strcmp("cc1101_ext", device->name) == 0) {
if(furi_hal_subghz_get_ext_power_amp()) {
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
}
}
device->interconnect->end();
}
}
@@ -98,12 +77,6 @@ void subghz_devices_idle(const SubGhzDevice* device) {
furi_assert(device);
if(device->interconnect->idle) {
device->interconnect->idle();
// TODO: Remake this check and move this code
if(strcmp("cc1101_ext", device->name) == 0) {
if(furi_hal_subghz_get_ext_power_amp()) {
furi_hal_gpio_write(&gpio_ext_pc3, 0);
}
}
}
}
@@ -156,13 +129,6 @@ bool subghz_devices_set_tx(const SubGhzDevice* device) {
furi_assert(device);
if(device->interconnect->set_tx) {
ret = device->interconnect->set_tx();
// TODO: Remake this check and move this code
if(strcmp("cc1101_ext", device->name) == 0) {
if(furi_hal_subghz_get_ext_power_amp()) {
furi_hal_gpio_write(&gpio_ext_pc3, 1);
}
}
}
return ret;
}
@@ -203,13 +169,6 @@ void subghz_devices_set_rx(const SubGhzDevice* device) {
furi_assert(device);
if(device->interconnect->set_rx) {
device->interconnect->set_rx();
// TODO: Remake this check and move this code
if(strcmp("cc1101_ext", device->name) == 0) {
if(furi_hal_subghz_get_ext_power_amp()) {
furi_hal_gpio_write(&gpio_ext_pc3, 0);
}
}
}
}
+10 -2
View File
@@ -12,12 +12,14 @@
#include <flipper_application/flipper_application.h>
#define SUBGHZ_RADIO_DEVICE_PLUGIN_APP_ID "subghz_radio_device"
#define SUBGHZ_RADIO_DEVICE_PLUGIN_API_VERSION 1
#define SUBGHZ_RADIO_DEVICE_PLUGIN_API_VERSION 2
typedef struct SubGhzDeviceRegistry SubGhzDeviceRegistry;
typedef struct SubGhzDevice SubGhzDevice;
typedef struct SubGhzDeviceConf SubGhzDeviceConf;
typedef bool (*SubGhzBegin)(void);
// typedef bool (*SubGhzBegin)(void);
typedef bool (*SubGhzBegin)(SubGhzDeviceConf* conf);
typedef void (*SubGhzEnd)(void);
typedef bool (*SubGhzIsConnect)(void);
typedef void (*SubGhzReset)(void);
@@ -89,3 +91,9 @@ struct SubGhzDevice {
const char* name;
const SubGhzDeviceInterconnect* interconnect;
};
struct SubGhzDeviceConf {
uint8_t ver;
bool extended_range;
bool power_amp;
};