Files
hpw421/component/xc6xx_drivers/Drivers/test_case/ADC/pga_adc.h
T
2026-06-06 16:49:48 +08:00

91 lines
3.0 KiB
C

/*!
* \file pga_adc.h
*
* \brief The head file of pga_adc.h
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
*
* _ __ _ ________ _
* | |/ /(_)___ / ____/ /_ (_)___
* | // / __ \/ / / __ \/ / __ \
* / |/ / / / / /___/ / / / / /_/ /
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
* /_/
* (C) 2022-2025 XinChip
*
* \endcode
*
* \author ( XinChip ) Alex-J
*
* \author ( XinChip )
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __BSP_PGA_ADC_H_
#define __BSP_PGA_ADC_H_
/*-----------------------------------------------------------------------------------
INCLUDE HEADE FILES
------------------------------------------------------------------------------------*/
#include "stdint.h"
#include "xc60xx.h"
/*------------------------------------------------------------------------------------
Macros
-------------------------------------------------------------------------------------*/
#define SAMPLING_DEBUG 1
#define REC_TEST_EN 1 //录音测试,定时录音
#define ADC_CLOCK_FREQ_8M ADC_CLK_DIV_0 // ADC_FREQ_8M
#define ADC_CLOCK_FREQ_4M ADC_CLK_DIV_2 // ADC_FREQ_4M
#define ADC_CLOCK_FREQ_2M ADC_CLK_DIV_4 // ADC_FREQ_2M
#define ADC_CLOCK_FREQ_1M ADC_CLK_DIV_8 // ADC_FREQ_1M
#define ADC_CLOCK_FREQ_500K ADC_CLK_DIV_16 // ADC_FREQ_500K
#define ADC_FREQ_CLOCK ADC_CLK_DIV_4 // ADC时钟选择
#define MIC_SAMPLING_8K 0
#define MIC_SAMPLING_16K 1
#define SAMPLING_TYPE MIC_SAMPLING_16K
#define MIC_SAMPLING_MAX_LEN 1 * 256 //缓冲长度,根据需求调节
/*------------------------------------------------------------------------------------
TypeDef
-------------------------------------------------------------------------------------*/
typedef struct {
short mic_adc_buff[2][MIC_SAMPLING_MAX_LEN]; //双缓存buff,方便读取以及采样
uint16_t pga_adc_rx_index; //缓存buff下标
uint8_t
save_buf_index; //双缓存buff下标,存放第几个mic_adc_buff[save_buf_index][]
uint8_t buf_full_flag;
uint8_t freq_con; //采样率计算
#if SAMPLING_DEBUG
uint32_t pga_adc_rx_con;
uint8_t rx_flag;
#endif
#if REC_TEST_EN || SAMPLING_DEBUG
uint8_t rec_len_time;
#endif
} Mic_sampling_cb;
/*------------------------------------------------------------------------------------
Global Variables
-------------------------------------------------------------------------------------*/
extern Mic_sampling_cb m_sampling_cb;
/*------------------------------------------------------------------------------------
Exported Functions
-------------------------------------------------------------------------------------*/
void audio_adc_rx_dma_event_handler(void);
void pga_adc_rx_event_handler(uint16_t pga_adc_val);
#endif