
/*
 * @file exo_io_al_adc_common.h
 *
 * @brief This file contains structures,enumerations
 * and function declaration for ADC interface
 *
 * @copyright Copyright 2023 Antaris, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef DRIVERS_EXO_HAL_DRIVER_FW_EXO_IO_AL_DRIVER_API_EXO_IO_AL_COMMON_ADC_INC_EXO_IO_AL_ADC_COMMON_H_
#define DRIVERS_EXO_HAL_DRIVER_FW_EXO_IO_AL_DRIVER_API_EXO_IO_AL_COMMON_ADC_INC_EXO_IO_AL_ADC_COMMON_H_

#include <stdint.h>
#include "exo_io_al_common.h"
#include "exo_hal_common.h"
#include "exo_hal_io_al_intr.h"
#include "exo_ahw_al_common.h"

#define ADC_INTF_ENB 1

typedef struct _ioal_adc_hdle
{
	ioal_intf_gen_info intf_gen_info;
}ioal_adc_hdle;

typedef struct
{
  uint32_t channel;

  uint32_t rank;
  uint32_t samplingtime;
  uint32_t offset;
}adc_channelconftypedef;


/* Prototype Definitions */
/**
 * @brief  This function initializes the ADC peripheral according to the specified
 *         parameters
 */
hal_ret_sts io_hal_adc_init(ioal_adc_hdle *ioal_hadc, io_inst_id inst_id);

/**
 * @brief  This function starts the ADC interface.
 * @param[in]  ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 *         the configuration information for the specified ADC.
 * @retval HAL status
 */
hal_ret_sts io_hal_adc_start(ioal_adc_hdle *hadc);

/**
 * @brief  This function stop the ADC interface.
 * @param[in]  ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 *                         the configuration information for the specified ADC.
 * @retval HAL status
 */
hal_ret_sts io_hal_adc_stop(ioal_adc_hdle *hadc);

/**
 * @brief This function used to PollForConversion
 * @param[in] ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 * @retval HAL status
 */
hal_ret_sts io_hal_adc_pollforconversion(ioal_adc_hdle *hadc, uint32_t Timeout);

/**
 * @brief This function used to Pollforevent
 * @param[in] ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 * @retval HAL status
 */
hal_ret_sts io_hal_adc_pollforevent(ioal_adc_hdle *hadc, uint32_t EventType, uint32_t Timeout);

/**
 * @brief  This function start_it in ADC.
 * @param[in]  ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 *                         the configuration information for the specified ADC.
 * @retval HAL status
 */
hal_ret_sts io_hal_adc_start_it(ioal_adc_hdle *hadc);

/**
 * @brief  This function stop_it in ADC.
 * @param[in]  ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 *         the configuration information for the specified ADC.
 * @retval HAL status
 */
hal_ret_sts io_hal_adc_stop_it(ioal_adc_hdle *hadc);

/**
 * @brief This function start the DMA mode.
 * @param[in] ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 * 							the configuration information for ADC.
 * @retval HAL status
 */
hal_ret_sts io_hal_adc_start_dma(ioal_adc_hdle *hadc, uint32_t* pData, uint32_t Length);

/**
 * @brief This function stop the DMA mode.
 * @param[in] ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 * 						  the configuration information for ADC.
 * @retval HAL status
 */
hal_ret_sts io_hal_adc_stop_dma(ioal_adc_hdle *hadc);

/**
 * @brief  This function get the ADC value state.
 * @param[in] ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 *         the configuration information for the specified ADC.
 * @retval HAL state
 */
uint32_t io_hal_adc_getvalue(ioal_adc_hdle *hadc);

/**
 * @brief This function config the channel.
 * @param[in] ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 * 						the configuration information for ADC.
 * @retval HAL status
 */
hal_ret_sts io_hal_adc_configchannel(ioal_adc_hdle *ioal_hadc, adc_channelconftypedef* sconfig);

/**
 * @brief This function configures the analog watchdog in ADC.
 * @param[in] ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 * 						the configuration information for ADC.
 * @retval HAL status
 */
hal_ret_sts io_hal_adc_analogwdgconfig(ioal_adc_hdle *ioal_hadc, adc_channelconftypedef* sconfig);

/**
 * @brief API to get the ADC state.
 * @param[in] ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 * 						  the configuration information for ADC.
 * @retval ADC State
 */
hal_ret_sts io_hal_adc_getstate(ioal_adc_hdle *hadc);

/**
 * @brief  This function get the ADC error state.
 * @param[in] ioal_hadc - ioal_hadc pointer to a ioal_adc_hdle structure that contains
 *         the configuration information for the specified ADC.
 * @retval HAL state
 */




hal_ret_sts io_hal_adc_geterror(ioal_adc_hdle *hadc);


#endif /* DRIVERS_EXO_HAL_DRIVER_FW_EXO_IO_AL_DRIVER_API_EXO_IO_AL_COMMON_ADC_INC_EXO_IO_AL_ADC_COMMON_H_ */
