/***********************************************************************
 * Copyright (c)  2017 - 2022, Unicmicro Co.,Ltd .
 * All rights reserved.
 * Filename    : continue_mode_mult_ch.c
 * Description : continue_mode_mult_ch source file
 * Author(s)   : Hackett
 * version     : V1.0
 * Modify date : 2022-07-10
 ***********************************************************************/
#include  "continue_mode_mult_ch.h"
#include  "common.h"
#include  "adc.h"
#include  "config.h"
#include  "app.h"


uint16_t g_continuous_data_tab[14][10] ={0};  //最大8个通道数据，每个通道10个字节宽度

/************************************************************************
 * Function   	: adc_continuous_mode_mult_ch_test
 * Description	: adc_continuous_mode_mult_ch_test adc多通道连续采样模式
 * Input 		: none
 * Output 		: none
 * Return		: none
 ************************************************************************/
void adc_continuous_mode_mult_ch_test(void)
{
	
	uint8_t i = 0;
	uint8_t j = 0;
	
	printfS("adc continue mode --- mult channel start!!!\r\n");
	
	adc_init(ADC_REF_VDDH,ADC_SAMPL_RATE_50K_SPS,ADC_CONTINUOUS_MODE);		//ADC初始化，选择ADC参考电压源、ADCCLK分频(2~65535)和采样模式

	adc_channel_gpio_config(ADC_CH1_EN|ADC_CH2_EN|ADC_CH3_EN, ADC_PF0|ADC_PA6|ADC_PB0);		//配置ADC转换通道

	adc_convert_start();
	
	/**************有效数据查询抓取到数据区**************/
	for(i=0; i<10; i++)
	{
		g_continuous_data_tab[1][i] = adc_get_data(1);
		g_continuous_data_tab[2][i] = adc_get_data(2);
		g_continuous_data_tab[3][i] = adc_get_data(3);		
	}
	/*************数据区打印*********************/
	j = 1;
	while(j < 4)
	{
		i = 0;
		while(i < 10)
		{
			printfS("g_continuous_data_tab[%d][%d] = %d, adc_vol = %.3fV\r\n",\
			j,i,g_continuous_data_tab[j][i],(float)g_continuous_data_tab[j][i]/4095*(float)3.3);
			i++;
		}
		printfS("\r\n");
		j++;
	}
	adc_convert_stop();


}
