1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 12:42:30 +04:00

Fix multiple bus issues in plugins

This commit is contained in:
MX
2023-06-02 23:32:23 +03:00
parent e990e58177
commit 13a1cd32a7
8 changed files with 34 additions and 14 deletions

View File

@@ -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)

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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. */

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -18,6 +18,8 @@ void wav_player_dma_start();
void wav_player_dma_stop();
void wav_player_hal_deinit();
#ifdef __cplusplus
}
#endif