===============================================================================================
                ADC Multichannel Example
===============================================================================================
Copyright(C) Redpine Signals 2016
All rights reserved by Redpine Signals.

This program should be used on your own responsibility.
Redpine Signals assumes no responsibility for any losses
incurred by customers or third parties arising from the use of this file. 

===============================================================================================

===============================================================================================                                                       
Function description:
===============================================================================================
Enable the multiple ADC channel with different or same configuration.In this example four ADC 
channel configure with different sampling rate.

following configuration used in example for channel0: 
1.Sampling rate         : 1.2Msps 
2.Input type            : Single ended.
3.Positive input to ADC : ULP_GPIO4
4.Negative input to ADC : ULP_GPIO5,For single ended data acquisition this parameter not used.
5.Reference Voltage     : 2.8V (On LDO)(To change reference voltage modify 'vref_value' variable #line29)
6.Number of sample collection for each interrupt : 1024
9.Input Voltage range : 0.0V to 2.8V 

following configuration used in example for channel1: 
1.Sampling rate         : 625Ksps 
2.Input type            : Single ended.
3.Positive input to ADC : ULP_GPIO5
4.Negative input to ADC : ULP_GPIO5,For single ended data acquisition this parameter not used.
5.Reference Voltage     : 2.8V (On LDO)(To change reference voltage modify 'vref_value' variable #line29)
6.Number of sample collection for each interrupt : 1024
9.Input Voltage range : 0.0V to 2.8V 

following configuration used in example for channel2: 
1.Sampling rate         : 156Ksps 
2.Input type            : Single ended.
3.Positive input to ADC : ULP_GPIO6
4.Negative input to ADC : ULP_GPIO5,For single ended data acquisition this parameter not used.
5.Reference Voltage     : 2.8V (On LDO)(To change reference voltage modify 'vref_value' variable #line29)
6.Number of sample collection for each interrupt : 1024
9.Input Voltage range : 0.0V to 2.8V 

following configuration used in example for channel3: 
1.Sampling rate         : 156Ksps 
2.Input type            : Single ended.
3.Positive input to ADC : ULP_GPIO7
4.Negative input to ADC : ULP_GPIO5,For single ended data acquisition this parameter not used.
5.Reference Voltage     : 2.8V (On LDO)(To change reference voltage modify 'vref_value' variable #line29)
6.Number of sample collection for each interrupt : 1024
9.Input Voltage range : 0.0V to 2.8V 

For configuring multiple channel sampling rate follow below guidelines,
1.Maximum sampling rate for single channel is 2.5Msps
2.To configure enabled ADC channels sampling rate,Channel[0] must be highest sampling rate and reaming channels
sampling rate should be less then or equal channel0 sampling rate.
For example , 
If i = (channel number) , Sampling rate of Channel[i] = (Channel[i-1] or (Channel[i-1]/2) or (Channel[i-1]/4) so on)
e.g i = 2; then Sampling rate of Channel[2] = (Channel[2-1] or (Channel[2-1]/2) or (Channel[2-1]/4) so on).

Read the 1.achived_sampling_rate[0] = Configured channel0 sampling rate to ADC.
         2.achived_sampling_rate[1] = Configured channel1 sampling rate to ADC.
		 3.achived_sampling_rate[2] = Configured channel2 sampling rate to ADC.
		 4.achived_sampling_rate[3] = Configured channel3 sampling rate to ADC.	
===============================================================================================
Environment
===============================================================================================
Test Board:
---------------------
Smart EVK Rev1.2

Assistance software:
---------------------
None
===============================================================================================
MACRO usage
===============================================================================================
1.'MULTICHANNEL_ENABLE'(#line41 in rsi_adc.h file)
Enable macro for multiple channel data acquisition,here MULTICHANNEL_ENABLE already define
in (Options for Target --> C/C++ -->Define) 

2.'PS2_STATE_ADC_DATA_AQU_ENABLE'(#line38 in rsi_adc.h file)
Enable this macro if code is running in PS2 state.
Enable this macro for PS4 state and flash based execution.

3.'CORE_CLOCK_180MHZ'
Enable this macro as one to switch M4 clock to 180Mhz.

4.'NUMBER_OF_CHA_EN' 
Number of channel enable for data acquisition.

5.'CHANNEL0_SAMPLE_LENGTH'
Sample to collect for channel0.
maximum samples can be collect 1024.

6.'CHANNEL1_SAMPLE_LENGTH'
Sample to collect for channel1.
maximum samples can be collect 1024.

7.'CHANNEL2_SAMPLE_LENGTH'
Sample to collect for channel2.
maximum samples can be collect 1024.

8.'CHANNEL3_SAMPLE_LENGTH'
Sample to collect for channel3.
maximum samples can be collect 1024.
===============================================================================================
Pass criteria:
===============================================================================================
Enable ENOB macro to verify channels functionality,here after enabling ENOB macro code will 
stop after collecting 2048 samples for each channels.
Read adc_channel0_result[] for channel0 data.
Read adc_channel1_result[] for channel1 data.
Read adc_channel2_result[] for channel2 data.
Read adc_channel3_result[] for channel3 data.

Disable ENOB macro and process each channel 1024 samples.
===============================================================================================
Note : 
===============================================================================================
1.Make this macro as one for multiple channel data acquisition,here MULTICHANNEL_ENABLE already define
  in (Options for Target --> C/C++ -->Define) 
2.For PS2 state data acquisition make '#define PS2_STATE_ADC_DATA_AQU_ENABLE'(#line38 in rsi_adc.h file)  
===============================================================================================