Metal Detector
 
Loading...
Searching...
No Matches
app_signal.c File Reference

Implementation file for signal processing and FFT operations. More...

#include "adc.h"
#include "dac.h"
#include "tim.h"
#include "lvgl.h"
#include "ui.h"
#include "app_tasks.h"
#include "app_signal.h"

Functions

void sig_start (SIG_Handle_t *const handle)
 Initializes and starts the signal processing components.
 
void sig_load_samples (SIG_Handle_t *const handle, uint8_t flag)
 Loads samples into the processing buffers.
 
size_t sig_perform_fft (SIG_Handle_t *const handle)
 Performs Fast Fourier Transform (FFT) on the signal data.
 
void HAL_ADC_ConvCpltCallback (ADC_HandleTypeDef *hadc)
 Callback function for ADC conversion complete interrupt.
 
void HAL_ADC_ConvHalfCpltCallback (ADC_HandleTypeDef *hadc)
 Callback function for ADC half conversion complete interrupt.
 

Variables

const uint32_t OUTPUT_SINE_SIGNAL [OUTPUT_SINE_SIGNAL_LEN] = {2048, 3251, 3995, 3996, 3253, 2051, 847, 101, 98, 839}
 
const uint32_t OUTPUT_AUDIO_SIGNAL [OUTPUT_SINE_AUDIO_LEN]
 
SIG_Handle_t sig_handle = {0}
 

Detailed Description

Implementation file for signal processing and FFT operations.

This file contains the implementation for handling signal processing tasks, including ADC and DAC setup, sample loading, and FFT operations. Functions include initialization of ADC and DAC, loading samples from the ADC buffer, performing FFT, and handling ADC conversion complete callbacks. The file interfaces with the hardware and performs signal analysis using the CMSIS DSP library.

Created on: Jul 5, 2024 Author: Viktor

Function Documentation

◆ HAL_ADC_ConvCpltCallback()

void HAL_ADC_ConvCpltCallback ( ADC_HandleTypeDef * hadc)

Callback function for ADC conversion complete interrupt.

This function is called when the ADC conversion is complete. It places a flag in the message queue to indicate that the ADC data is ready for processing.

Parameters
hadcPointer to the ADC_HandleTypeDef structure.

◆ HAL_ADC_ConvHalfCpltCallback()

void HAL_ADC_ConvHalfCpltCallback ( ADC_HandleTypeDef * hadc)

Callback function for ADC half conversion complete interrupt.

This function is called when half of the ADC conversion is complete. It places a flag in the message queue to indicate that the first half of the ADC data is ready for processing.

Parameters
hadcPointer to the ADC_HandleTypeDef structure.

◆ sig_load_samples()

void sig_load_samples ( SIG_Handle_t *const handle,
uint8_t flag )

Loads samples into the processing buffers.

Loads samples from the ADC buffer into the processing buffers.

This function copies samples from the input buffer to the processing buffers for further signal analysis. The samples are loaded based on the provided flag.

Parameters
handlePointer to the SIG_Handle_t structure containing the buffers.
flagFlag indicating the completion status of ADC conversion.

◆ sig_perform_fft()

size_t sig_perform_fft ( SIG_Handle_t *const handle)

Performs Fast Fourier Transform (FFT) on the signal data.

Performs FFT on the loaded signal data and computes magnitude and phase.

This function calculates the FFT of the input signals for both the receive and transmit coils. It then computes the magnitude and phase of the frequency domain data and returns the index of the maximum magnitude value.

Parameters
handlePointer to the SIG_Handle_t structure containing the signal data.
Returns
size_t Index of the maximum magnitude value in the frequency domain.

◆ sig_start()

void sig_start ( SIG_Handle_t *const handle)

Initializes and starts the signal processing components.

Starts the signal processing by initializing ADC and DAC, and starting timers.

This function initializes the ADC and DAC peripherals, starts the ADC conversion in DMA mode, and begins the DAC output with a sine wave signal. It also starts the timer used for signal processing.

Parameters
handlePointer to the SIG_Handle_t structure containing the configuration.

Variable Documentation

◆ OUTPUT_AUDIO_SIGNAL

const uint32_t OUTPUT_AUDIO_SIGNAL[OUTPUT_SINE_AUDIO_LEN]
Initial value:
= {
2048, 2176, 2304,
2431, 2557, 2680, 2801, 2919, 3034, 3145, 3251, 3353, 3449, 3540, 3625,
3704, 3776, 3842, 3900, 3951, 3995, 4031, 4059, 4079, 4091, 4095, 4091,
4079, 4059, 4031, 3995, 3951, 3900, 3842, 3776, 3704, 3625, 3540, 3449,
3353, 3251, 3145, 3034, 2919, 2801, 2680, 2557, 2431, 2304, 2176, 2047,
1919, 1791, 1664, 1538, 1415, 1294, 1176, 1061, 950, 844, 742, 646, 555,
470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100,
144, 195, 253, 319, 391, 470, 555, 646, 742, 844, 950, 1061, 1176, 1294,
1415, 1538, 1664, 1791, 1919
}

◆ sig_handle

SIG_Handle_t sig_handle = {0}

Global handle for signal processing