/** \brief AUTOSAR MCAL_test_adc
**
** This function contains the flow and implementation of the test
**
**
*/
#include <Adc.h>
#include <Adc_Cfg.h>
#include <Adc_PBcfg.h>
#include <Adc_Data.h>
#include <Adc_Types.h>
#include <Adc_Internal.h>
void test_adc(void) // Test code initialization and writing
{
uint8 adc_init;
uint8 groupstarts;
uint16 Adc_SetupResultBuffer[ADC_Group_2]; // ADC has three channel groups
/**
* @brief AdcGroup_SetupResultBuffer
*
* Description: Initializes ADC driver with the group specific result buffer start address
* where the conversion results will be stored. The application has to ensure that the application
* buffer, where DataBufferPtr points to, can hold all the conversion results of the
* specified group. The initialization with Adc_SetupResultBuffer is required after
* reset, before a group conversion can be started.
*
* Return_Type: E_OK: result buffer pointer initialized correctly
* E_NOT_OK: operation failed or development error occured
*
*/
for ( adc_init = 0 ; adc_init < ADC_Group_2; adc_init++ )
{
Adc_SetupResultBuffer[adc_init] = 0x5aa5; // The initial data is 0101 1010
}
/** \brief Adc_StartGroupConversion
**
** Starts the conversion of all channels of the requested ADC Channel group.
**
** Syntax: void Adc_StartGroupConversion(
** Adc_GroupType Group
** )
*/
/**
* @brief AdcConf_AdcGroup_AdcGroup_HW0_0
* Symbolic Names of Groups
* AdcConf_AdcGroup_AdcGroup_HW0_0
* @return ** void
*/
void Adc_StartGroupConversion(AdcConf_AdcGroup_AdcGroup_HW0_0);
{
return ;
}
/**
* @brief AdcConf_AdcGroup_AdcGroup_HW1_0
* Symbolic Names of Groups
* AdcConf_AdcGroup_AdcGroup_HW1_0
* @return ** void
*/
void Adc_StartGroupConversion(AdcConf_AdcGroup_AdcGroup_HW1_0);
{
return ;
}
/**
* @brief AdcConf_AdcGroup_AdcGroup_HW2_0
* Symbolic Names of Groups
* AdcConf_AdcGroup_AdcGroup_HW2_0
* @return ** void
*/
void Adc_StartGroupConversion(AdcConf_AdcGroup_AdcGroup_HW2_0);
{
return ;
}
/**
* @brief Adc_GroupStatusList
*
* Returns the conversion status of the requested ADC Channel group.
* Available via: Adc.h
*
*/
while(Adc_GroupStatusList != ADC_BUSY)
{
groupstarts = Adc_GetGroupStatusList(AdcConf_AdcGroup_AdcGroup_HW0_0);
groupstarts = Adc_GetGroupStatusList(AdcConf_AdcGroup_AdcGroup_HW1_0);
groupstarts = Adc_GetGroupStatusList(AdcConf_AdcGroup_AdcGroup_HW2_0);
}
/**
* @brief Adc_ReadGroup
*
* Std_ReturnType Adc_ReadGroup(
* Adc_GroupType Group,
* Adc_ValueGroupType* DataBufferPtr
* )
*
* Description: Reads the group conversion result of the last completed conversion
* round of the requested group and stores the channel values starting at the DataBufferPtr
* address. The group channel values are stored in ascending channel number order
* ( in contrast to the storage layout of the result buffer if streaming access is
* configured).
*
* Return value:E_OK: results are available and written to the data buffer
* E_NOT_OK: no results are available or development error occured
*/
if(Adc_GetGroupStatusList == ADC_BUSY)
{
(void)Adc_ReadGroup(AdcConf_AdcGroup_AdcGroup_HW0_0 ,Adc_ValueGroupType* ADC_CFG0_CHANNEL_CONFIGS );
{
return ; // Reads data from a channel group
}
(void)Adc_ReadGroup(AdcConf_AdcGroup_AdcGroup_HW1_0 ,Adc_ValueGroupType* ADC_CFG0_CHANNEL_CONFIGS );
{
return ;
}
(void)Adc_ReadGroup(AdcConf_AdcGroup_AdcGroup_HW2_0 ,Adc_ValueGroupType* ADC_CFG0_CHANNEL_CONFIGS );
{
return ;
}
}
}
ADC Driver test
最新推荐文章于 2024-06-03 14:50:03 发布