ADC Driver test

/** \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 ;       
                    }
    }
    
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值