Update ampd code again

This commit is contained in:
Sil333033
2023-07-29 22:18:22 +02:00
parent b3a783acb4
commit 5103a45f0a
3 changed files with 14 additions and 11 deletions

View File

@@ -7,6 +7,7 @@
#include <furi_hal_interrupt.h>
#include <furi_hal_resources.h>
#include <furi_hal_bus.h>
#include <furi_hal_subghz.h>
#include <stm32wbxx_ll_dma.h>
#include <furi_hal_cortex.h>
@@ -204,7 +205,8 @@ bool subghz_device_cc1101_ext_alloc() {
&furi_hal_spi_bus_handle_external_extra);
// this is needed if multiple SPI devices are connected to the same bus but with different CS pins
if(XTREME_SETTINGS()->spi_cc1101_handle == SpiDefault) {
if(XTREME_SETTINGS()->spi_cc1101_handle == SpiDefault &&
!furi_hal_subghz_get_ext_power_amp()) {
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
furi_hal_gpio_write(&gpio_ext_pc3, true);
} else if(XTREME_SETTINGS()->spi_cc1101_handle == SpiExtra) {

View File

@@ -119,6 +119,7 @@ static void subghz_scene_reciever_config_set_ext_mod_power_amp_text(VariableItem
if(index == 1) {
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
furi_hal_gpio_write(&gpio_ext_pc3, 0);
} else {
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
}

View File

@@ -7,16 +7,6 @@
void subghz_devices_init() {
furi_check(!subghz_device_registry_is_valid());
subghz_device_registry_init();
SubGhzLastSettings* last_settings = subghz_last_settings_alloc();
subghz_last_settings_load(last_settings, 0);
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);
}
void subghz_devices_deinit(void) {
@@ -48,6 +38,16 @@ bool subghz_devices_begin(const SubGhzDevice* 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);
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);
}