diff --git a/CHANGELOG.md b/CHANGELOG.md index e4d511dcd..654060c85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * Infrared: Update universal remote assets (by @amec0e) * GUI Keyboard: Fix crash when renaming files with long file name (Fixed issue #489) * Misc: Fix APP_IDs to match new regex (regex check will be added in OFW soon) +* Plugins: Protoview, WAV Player, DTMF Dolphin - fixed all known crashes, ported to latest hal bus system * Plugins: ESP8266 Deauther - Crash fix (Fixed issue #497) * Plugins: Update -> Mifare Nested [(by AloneLiberty)](https://github.com/AloneLiberty/FlipperNested) * Plugins: Update -> TOTP (Authenticator) [(by akopachov)](https://github.com/akopachov/flipper-zero_authenticator) diff --git a/applications/external/dtmf_dolphin/dtmf_dolphin_audio.c b/applications/external/dtmf_dolphin/dtmf_dolphin_audio.c index 2ec24c7ba..66d17bc2e 100644 --- a/applications/external/dtmf_dolphin/dtmf_dolphin_audio.c +++ b/applications/external/dtmf_dolphin/dtmf_dolphin_audio.c @@ -214,12 +214,12 @@ bool dtmf_dolphin_audio_play_tones( generate_waveform(current_player, 0); generate_waveform(current_player, current_player->half_buffer_length); - dtmf_dolphin_speaker_init(); dtmf_dolphin_dma_init((uint32_t)current_player->sample_buffer, current_player->buffer_length); furi_hal_interrupt_set_isr( FuriHalInterruptIdDma1Ch1, dtmf_dolphin_audio_dma_isr, current_player->queue); if(furi_hal_speaker_acquire(1000)) { + dtmf_dolphin_speaker_init(); dtmf_dolphin_dma_start(); dtmf_dolphin_speaker_start(); current_player->playing = true; diff --git a/applications/external/protoview/app_subghz.c b/applications/external/protoview/app_subghz.c index 69197df5c..dcb6d492b 100644 --- a/applications/external/protoview/app_subghz.c +++ b/applications/external/protoview/app_subghz.c @@ -173,6 +173,8 @@ void protoview_timer_isr(void* ctx) { void raw_sampling_worker_start(ProtoViewApp* app) { UNUSED(app); + furi_hal_bus_enable(FuriHalBusTIM2); + LL_TIM_InitTypeDef tim_init = { .Prescaler = 63, /* CPU frequency is ~64Mhz. */ .CounterMode = LL_TIM_COUNTERMODE_UP, @@ -195,6 +197,6 @@ void raw_sampling_worker_stop(ProtoViewApp* app) { LL_TIM_DisableCounter(TIM2); LL_TIM_DisableIT_UPDATE(TIM2); furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, NULL, NULL); - LL_TIM_DeInit(TIM2); + furi_hal_bus_disable(FuriHalBusTIM2); FURI_CRITICAL_EXIT(); } diff --git a/applications/external/protoview/protocols/unknown.c b/applications/external/protoview/protocols/unknown.c index 9e2f4a893..ec87d59b9 100644 --- a/applications/external/protoview/protocols/unknown.c +++ b/applications/external/protoview/protocols/unknown.c @@ -251,7 +251,7 @@ static bool decode(uint8_t* bits, uint32_t numbytes, uint32_t numbits, ProtoView linecode = LineCodeManchester; start1 = tmp1; msgbits = manchester_bits * 2; - FURI_LOG_E(TAG, "MANCHESTER START: %lu", tmp1); + //FURI_LOG_T(TAG, "MANCHESTER START: %lu", tmp1); } if(linecode == LineCodeNone) return false; @@ -284,11 +284,11 @@ static bool decode(uint8_t* bits, uint32_t numbytes, uint32_t numbits, ProtoView * transfer all that is needed, like a message * terminator (that we don't detect). */ - if(preamble_found) FURI_LOG_E(TAG, "PREAMBLE AT: %lu", preamble_start); - FURI_LOG_E(TAG, "START: %lu", info->start_off); - FURI_LOG_E(TAG, "MSGBITS: %lu", msgbits); - FURI_LOG_E(TAG, "DATASTART: %lu", start1); - FURI_LOG_E(TAG, "PULSES: %lu", info->pulses_count); + /*if(preamble_found) FURI_LOG_T(TAG, "PREAMBLE AT: %lu", preamble_start); + FURI_LOG_T(TAG, "START: %lu", info->start_off); + FURI_LOG_T(TAG, "MSGBITS: %lu", msgbits); + FURI_LOG_T(TAG, "DATASTART: %lu", start1); + FURI_LOG_T(TAG, "PULSES: %lu", info->pulses_count);*/ /* We think there is a message and we know where it starts and the * line code used. We can turn it into bits and bytes. */ diff --git a/applications/external/protoview/view_direct_sampling.c b/applications/external/protoview/view_direct_sampling.c index 0268e5297..84486dc51 100644 --- a/applications/external/protoview/view_direct_sampling.c +++ b/applications/external/protoview/view_direct_sampling.c @@ -137,6 +137,8 @@ static void ds_timer_isr(void* ctx) { static void direct_sampling_timer_start(ProtoViewApp* app) { DirectSamplingViewPrivData* privdata = app->view_privdata; + furi_hal_bus_enable(FuriHalBusTIM2); + LL_TIM_InitTypeDef tim_init = { .Prescaler = 63, /* CPU frequency is ~64Mhz. */ .CounterMode = LL_TIM_COUNTERMODE_UP, @@ -157,6 +159,6 @@ static void direct_sampling_timer_stop(ProtoViewApp* app) { LL_TIM_DisableCounter(TIM2); LL_TIM_DisableIT_UPDATE(TIM2); furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, NULL, NULL); - LL_TIM_DeInit(TIM2); + furi_hal_bus_disable(FuriHalBusTIM2); FURI_CRITICAL_EXIT(); } diff --git a/applications/external/wav_player/wav_player.c b/applications/external/wav_player/wav_player.c index 8f3273131..3a48f41e8 100644 --- a/applications/external/wav_player/wav_player.c +++ b/applications/external/wav_player/wav_player.c @@ -357,12 +357,12 @@ static void app_run(WavPlayerApp* app) { bool eof = fill_data(app, 0); eof = fill_data(app, app->samples_count_half); - wav_player_speaker_init(app->sample_rate); - wav_player_dma_init((uint32_t)app->sample_buffer, app->samples_count); - - furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, wav_player_dma_isr, app->queue); - if(furi_hal_speaker_acquire(1000)) { + wav_player_speaker_init(app->sample_rate); + wav_player_dma_init((uint32_t)app->sample_buffer, app->samples_count); + + furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, wav_player_dma_isr, app->queue); + wav_player_dma_start(); wav_player_speaker_start(); @@ -440,6 +440,9 @@ static void app_run(WavPlayerApp* app) { furi_hal_speaker_release(); } + // Reset GPIO pin and bus states + wav_player_hal_deinit(); + furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, NULL, NULL); } diff --git a/applications/external/wav_player/wav_player_hal.c b/applications/external/wav_player/wav_player_hal.c index 40f7a3ff5..cf2688523 100644 --- a/applications/external/wav_player/wav_player_hal.c +++ b/applications/external/wav_player/wav_player_hal.c @@ -17,6 +17,9 @@ #define DMA_INSTANCE DMA1, LL_DMA_CHANNEL_1 void wav_player_speaker_init(uint32_t sample_rate) { + // Enable bus + furi_hal_bus_enable(FuriHalBusTIM2); + LL_TIM_InitTypeDef TIM_InitStruct = {0}; //TIM_InitStruct.Prescaler = 4; TIM_InitStruct.Prescaler = 1; @@ -56,6 +59,13 @@ void wav_player_speaker_init(uint32_t sample_rate) { GpioAltFn14TIM16); } +void wav_player_hal_deinit() { + furi_hal_gpio_init(&gpio_ext_pa6, GpioModeAnalog, GpioPullNo, GpioSpeedLow); + + // Disable bus + furi_hal_bus_disable(FuriHalBusTIM2); +} + void wav_player_speaker_start() { LL_TIM_EnableAllOutputs(FURI_HAL_SPEAKER_TIMER); LL_TIM_EnableCounter(FURI_HAL_SPEAKER_TIMER); diff --git a/applications/external/wav_player/wav_player_hal.h b/applications/external/wav_player/wav_player_hal.h index 124f51406..bddfc3fed 100644 --- a/applications/external/wav_player/wav_player_hal.h +++ b/applications/external/wav_player/wav_player_hal.h @@ -18,6 +18,8 @@ void wav_player_dma_start(); void wav_player_dma_stop(); +void wav_player_hal_deinit(); + #ifdef __cplusplus } #endif \ No newline at end of file