mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-21 05:04:46 -07:00
Fix issues with external module 5v power
This commit is contained in:
@@ -402,7 +402,8 @@ bool unirfremix_key_load(
|
|||||||
preset->decoder = subghz_receiver_search_decoder_base_by_name(
|
preset->decoder = subghz_receiver_search_decoder_base_by_name(
|
||||||
receiver, furi_string_get_cstr(preset->protocol));
|
receiver, furi_string_get_cstr(preset->protocol));
|
||||||
if(preset->decoder) {
|
if(preset->decoder) {
|
||||||
SubGhzProtocolStatus status = subghz_protocol_decoder_base_deserialize(preset->decoder, fff_data);
|
SubGhzProtocolStatus status =
|
||||||
|
subghz_protocol_decoder_base_deserialize(preset->decoder, fff_data);
|
||||||
if(status != SubGhzProtocolStatusOk) {
|
if(status != SubGhzProtocolStatusOk) {
|
||||||
FURI_LOG_E(TAG, "Protocol deserialize failed, status = %d", status);
|
FURI_LOG_E(TAG, "Protocol deserialize failed, status = %d", status);
|
||||||
break;
|
break;
|
||||||
@@ -736,6 +737,8 @@ UniRFRemix* unirfremix_alloc(void) {
|
|||||||
UniRFRemix* app = malloc(sizeof(UniRFRemix));
|
UniRFRemix* app = malloc(sizeof(UniRFRemix));
|
||||||
|
|
||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
// Enable power for External CC1101 if it is connected
|
||||||
|
furi_hal_subghz_enable_ext_power();
|
||||||
|
|
||||||
app->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
app->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||||
|
|
||||||
@@ -757,6 +760,9 @@ UniRFRemix* unirfremix_alloc(void) {
|
|||||||
void unirfremix_free(UniRFRemix* app, bool with_subghz) {
|
void unirfremix_free(UniRFRemix* app, bool with_subghz) {
|
||||||
furi_hal_power_suppress_charge_exit();
|
furi_hal_power_suppress_charge_exit();
|
||||||
|
|
||||||
|
// Disable power for External CC1101 if it was enabled and module is connected
|
||||||
|
furi_hal_subghz_disable_ext_power();
|
||||||
|
|
||||||
furi_string_free(app->up_file);
|
furi_string_free(app->up_file);
|
||||||
furi_string_free(app->down_file);
|
furi_string_free(app->down_file);
|
||||||
furi_string_free(app->left_file);
|
furi_string_free(app->left_file);
|
||||||
|
|||||||
@@ -674,6 +674,9 @@ int32_t playlist_app(void* p) {
|
|||||||
|
|
||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
|
||||||
|
// Enable power for External CC1101 if it is connected
|
||||||
|
furi_hal_subghz_enable_ext_power();
|
||||||
|
|
||||||
// select playlist file
|
// select playlist file
|
||||||
{
|
{
|
||||||
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
|
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
|
||||||
@@ -752,6 +755,8 @@ int32_t playlist_app(void* p) {
|
|||||||
exit_cleanup:
|
exit_cleanup:
|
||||||
|
|
||||||
furi_hal_power_suppress_charge_exit();
|
furi_hal_power_suppress_charge_exit();
|
||||||
|
// Disable power for External CC1101 if it was enabled and module is connected
|
||||||
|
furi_hal_subghz_disable_ext_power();
|
||||||
|
|
||||||
if(app->worker != NULL) {
|
if(app->worker != NULL) {
|
||||||
if(playlist_worker_running(app->worker)) {
|
if(playlist_worker_running(app->worker)) {
|
||||||
|
|||||||
@@ -124,6 +124,9 @@ POCSAGPagerApp* pocsag_pager_app_alloc() {
|
|||||||
|
|
||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
|
||||||
|
// Enable power for External CC1101 if it is connected
|
||||||
|
furi_hal_subghz_enable_ext_power();
|
||||||
|
|
||||||
scene_manager_next_scene(app->scene_manager, POCSAGPagerSceneStart);
|
scene_manager_next_scene(app->scene_manager, POCSAGPagerSceneStart);
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
@@ -135,6 +138,9 @@ void pocsag_pager_app_free(POCSAGPagerApp* app) {
|
|||||||
//CC1101 off
|
//CC1101 off
|
||||||
pcsg_sleep(app);
|
pcsg_sleep(app);
|
||||||
|
|
||||||
|
// Disable power for External CC1101 if it was enabled and module is connected
|
||||||
|
furi_hal_subghz_disable_ext_power();
|
||||||
|
|
||||||
// Submenu
|
// Submenu
|
||||||
view_dispatcher_remove_view(app->view_dispatcher, POCSAGPagerViewSubmenu);
|
view_dispatcher_remove_view(app->view_dispatcher, POCSAGPagerViewSubmenu);
|
||||||
submenu_free(app->submenu);
|
submenu_free(app->submenu);
|
||||||
|
|||||||
@@ -170,6 +170,9 @@ ProtoViewApp* protoview_app_alloc() {
|
|||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
app->running = 1;
|
app->running = 1;
|
||||||
|
|
||||||
|
// Enable power for External CC1101 if it is connected
|
||||||
|
furi_hal_subghz_enable_ext_power();
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +185,9 @@ void protoview_app_free(ProtoViewApp* app) {
|
|||||||
// Put CC1101 on sleep, this also restores charging.
|
// Put CC1101 on sleep, this also restores charging.
|
||||||
radio_sleep(app);
|
radio_sleep(app);
|
||||||
|
|
||||||
|
// Disable power for External CC1101 if it was enabled and module is connected
|
||||||
|
furi_hal_subghz_disable_ext_power();
|
||||||
|
|
||||||
// View related.
|
// View related.
|
||||||
view_port_enabled_set(app->view_port, false);
|
view_port_enabled_set(app->view_port, false);
|
||||||
gui_remove_view_port(app->gui, app->view_port);
|
gui_remove_view_port(app->gui, app->view_port);
|
||||||
|
|||||||
@@ -392,6 +392,9 @@ void spectrum_analyzer_free(SpectrumAnalyzer* instance) {
|
|||||||
|
|
||||||
furi_hal_subghz_idle();
|
furi_hal_subghz_idle();
|
||||||
furi_hal_subghz_sleep();
|
furi_hal_subghz_sleep();
|
||||||
|
|
||||||
|
// Disable power for External CC1101 if it was enabled and module is connected
|
||||||
|
furi_hal_subghz_disable_ext_power();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t spectrum_analyzer_app(void* p) {
|
int32_t spectrum_analyzer_app(void* p) {
|
||||||
@@ -402,6 +405,9 @@ int32_t spectrum_analyzer_app(void* p) {
|
|||||||
|
|
||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
|
||||||
|
// Enable power for External CC1101 if it is connected
|
||||||
|
furi_hal_subghz_enable_ext_power();
|
||||||
|
|
||||||
FURI_LOG_D("Spectrum", "Main Loop - Starting worker");
|
FURI_LOG_D("Spectrum", "Main Loop - Starting worker");
|
||||||
furi_delay_ms(50);
|
furi_delay_ms(50);
|
||||||
|
|
||||||
|
|||||||
Submodule applications/plugins/subbrute updated: 7cdb9e1386...552bd12d0f
@@ -107,6 +107,9 @@ WeatherStationApp* weather_station_app_alloc() {
|
|||||||
|
|
||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
|
||||||
|
// Enable power for External CC1101 if it is connected
|
||||||
|
furi_hal_subghz_enable_ext_power();
|
||||||
|
|
||||||
scene_manager_next_scene(app->scene_manager, WeatherStationSceneStart);
|
scene_manager_next_scene(app->scene_manager, WeatherStationSceneStart);
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
@@ -118,6 +121,9 @@ void weather_station_app_free(WeatherStationApp* app) {
|
|||||||
//CC1101 off
|
//CC1101 off
|
||||||
ws_sleep(app);
|
ws_sleep(app);
|
||||||
|
|
||||||
|
// Disable power for External CC1101 if it was enabled and module is connected
|
||||||
|
furi_hal_subghz_disable_ext_power();
|
||||||
|
|
||||||
// Submenu
|
// Submenu
|
||||||
view_dispatcher_remove_view(app->view_dispatcher, WeatherStationViewSubmenu);
|
view_dispatcher_remove_view(app->view_dispatcher, WeatherStationViewSubmenu);
|
||||||
submenu_free(app->submenu);
|
submenu_free(app->submenu);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
static uint32_t furi_hal_subghz_debug_gpio_buff[2];
|
static uint32_t furi_hal_subghz_debug_gpio_buff[2];
|
||||||
static bool last_OTG_state = false;
|
static bool last_OTG_state = false;
|
||||||
|
static bool ext_power_is_enabled_already = false;
|
||||||
|
|
||||||
/* DMA Channels definition */
|
/* DMA Channels definition */
|
||||||
#define SUBGHZ_DMA DMA2
|
#define SUBGHZ_DMA DMA2
|
||||||
@@ -80,12 +81,16 @@ void furi_hal_subghz_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_enable_ext_power(void) {
|
void furi_hal_subghz_enable_ext_power(void) {
|
||||||
|
if(ext_power_is_enabled_already) return;
|
||||||
|
ext_power_is_enabled_already = true;
|
||||||
|
last_OTG_state = furi_hal_power_is_otg_enabled();
|
||||||
if(furi_hal_subghz.radio_type != SubGhzRadioInternal && !furi_hal_power_is_otg_enabled()) {
|
if(furi_hal_subghz.radio_type != SubGhzRadioInternal && !furi_hal_power_is_otg_enabled()) {
|
||||||
furi_hal_power_enable_otg();
|
furi_hal_power_enable_otg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_disable_ext_power(void) {
|
void furi_hal_subghz_disable_ext_power(void) {
|
||||||
|
ext_power_is_enabled_already = false;
|
||||||
if(furi_hal_subghz.radio_type != SubGhzRadioInternal && !last_OTG_state) {
|
if(furi_hal_subghz.radio_type != SubGhzRadioInternal && !last_OTG_state) {
|
||||||
furi_hal_power_disable_otg();
|
furi_hal_power_disable_otg();
|
||||||
}
|
}
|
||||||
@@ -97,6 +102,7 @@ bool furi_hal_subghz_check_radio(void) {
|
|||||||
furi_hal_subghz_enable_ext_power();
|
furi_hal_subghz_enable_ext_power();
|
||||||
|
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
||||||
|
|
||||||
uint8_t ver = cc1101_get_version(furi_hal_subghz.spi_bus_handle);
|
uint8_t ver = cc1101_get_version(furi_hal_subghz.spi_bus_handle);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
||||||
|
|
||||||
@@ -104,9 +110,10 @@ bool furi_hal_subghz_check_radio(void) {
|
|||||||
FURI_LOG_D(TAG, "Radio check ok");
|
FURI_LOG_D(TAG, "Radio check ok");
|
||||||
} else {
|
} else {
|
||||||
FURI_LOG_D(TAG, "Radio check failed");
|
FURI_LOG_D(TAG, "Radio check failed");
|
||||||
furi_hal_subghz_disable_ext_power();
|
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
furi_hal_subghz_disable_ext_power();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +124,6 @@ bool furi_hal_subghz_init_check(void) {
|
|||||||
furi_hal_subghz.state = SubGhzStateIdle;
|
furi_hal_subghz.state = SubGhzStateIdle;
|
||||||
furi_hal_subghz.preset = FuriHalSubGhzPresetIDLE;
|
furi_hal_subghz.preset = FuriHalSubGhzPresetIDLE;
|
||||||
|
|
||||||
last_OTG_state = furi_hal_power_is_otg_enabled();
|
|
||||||
furi_hal_subghz_enable_ext_power();
|
furi_hal_subghz_enable_ext_power();
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
||||||
|
|
||||||
@@ -169,8 +175,8 @@ bool furi_hal_subghz_init_check(void) {
|
|||||||
FURI_LOG_I(TAG, "Init OK");
|
FURI_LOG_I(TAG, "Init OK");
|
||||||
} else {
|
} else {
|
||||||
FURI_LOG_E(TAG, "Failed to initialization");
|
FURI_LOG_E(TAG, "Failed to initialization");
|
||||||
furi_hal_subghz_disable_ext_power();
|
|
||||||
}
|
}
|
||||||
|
furi_hal_subghz_disable_ext_power();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,6 +352,7 @@ void furi_hal_subghz_reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_idle() {
|
void furi_hal_subghz_idle() {
|
||||||
|
furi_hal_subghz_enable_ext_power();
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
||||||
cc1101_switch_to_idle(furi_hal_subghz.spi_bus_handle);
|
cc1101_switch_to_idle(furi_hal_subghz.spi_bus_handle);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
||||||
|
|||||||
Reference in New Issue
Block a user