Jelajahi Sumber

Merge dtmf_dolphin from https://github.com/xMasterX/all-the-plugins

Willy-JL 10 bulan lalu
induk
melakukan
664b6b041a

+ 1 - 1
dtmf_dolphin/.gitsubtree

@@ -1,2 +1,2 @@
-https://github.com/xMasterX/all-the-plugins dev base_pack/dtmf_dolphin 4558d74c9da36abc851edd96a95d18f7d5511a75
+https://github.com/xMasterX/all-the-plugins dev base_pack/dtmf_dolphin 8bc18d5d99262484548b6bbc92690a1472c329a0
 https://github.com/litui/dtmf_dolphin main /

+ 7 - 0
dtmf_dolphin/LICENSE

@@ -2,6 +2,7 @@
 
 DTMFDolphinAudio* current_player;
 
+// Interrupt handler. Read DMA flag and put correspondint event to queue. 
 static void dtmf_dolphin_audio_dma_isr(void* ctx) {
     FuriMessageQueue* event_queue = ctx;
 
@@ -216,8 +217,10 @@ bool dtmf_dolphin_audio_play_tones(
 
     dtmf_dolphin_dma_init((uint32_t)current_player->sample_buffer, current_player->buffer_length);
 
+    // Set interrupt handler.
     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();
@@ -244,6 +247,10 @@ bool dtmf_dolphin_audio_stop_tones() {
     dtmf_dolphin_dma_stop();
     furi_hal_speaker_release();
 
+    // Reset GPIO pin and bus states
+    dtmf_dolphin_gpio_deinit();
+
+    //Release interrrupt
     furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, NULL, NULL);
 
     dtmf_dolphin_audio_free(current_player);

+ 19 - 1
dtmf_dolphin/dtmf_dolphin_audio.h

@@ -11,6 +11,24 @@ void dtmf_dolphin_speaker_init() {
     TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_ENABLE;
     TIM_OC_InitStruct.CompareValue = 127;
     LL_TIM_OC_Init(FURI_HAL_SPEAKER_TIMER, FURI_HAL_SPEAKER_CHANNEL, &TIM_OC_InitStruct);
+
+    // Enable GPIO output
+    // Enable bus
+    furi_hal_bus_enable(FuriHalBusTIM2);
+
+    //configuring PA6 pin as TIM16 output
+    furi_hal_gpio_init_ex(
+        &gpio_ext_pa6,
+        GpioModeAltFunctionPushPull,
+        GpioPullNo,
+        GpioSpeedVeryHigh,
+        GpioAltFn14TIM16);
+}
+
+void dtmf_dolphin_gpio_deinit() {
+    // Disable GPIO output 
+    furi_hal_gpio_init(&gpio_ext_pa6, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
+    furi_hal_bus_disable(FuriHalBusTIM2);
 }
 
 void dtmf_dolphin_speaker_start() {
@@ -24,7 +42,7 @@ void dtmf_dolphin_speaker_stop() {
 }
 
 void dtmf_dolphin_dma_init(uint32_t address, size_t size) {
-    uint32_t dma_dst = (uint32_t) & (FURI_HAL_SPEAKER_TIMER->CCR1);
+    uint32_t dma_dst = (uint32_t)&(FURI_HAL_SPEAKER_TIMER->CCR1);
 
     LL_DMA_ConfigAddresses(DMA_INSTANCE, address, dma_dst, LL_DMA_DIRECTION_MEMORY_TO_PERIPH);
     LL_DMA_SetDataLength(DMA_INSTANCE, size);

+ 2 - 0
dtmf_dolphin/dtmf_dolphin_hal.h

@@ -28,6 +28,8 @@ void dtmf_dolphin_dma_start();
 
 void dtmf_dolphin_dma_stop();
 
+void dtmf_dolphin_gpio_deinit();
+
 #ifdef __cplusplus
 }
 #endif

+ 1 - 0
dtmf_dolphin/dtmf_dolphin_i.h

@@ -158,6 +158,7 @@ static void dtmf_dolphin_dialer_draw_callback(Canvas* canvas, void* _model) {
     if(model->gap_ms) {
         furi_string_cat_printf(output, "Gaps: %u ms\n", model->gap_ms);
     }
+    furi_string_cat_printf(output, "GPIO: PA6");
     elements_multiline_text(
         canvas, (max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 4, 21, furi_string_get_cstr(output));
 

+ 0 - 0
dtmf_dolphin/views/dtmf_dolphin_dialer.h