/**
  ******************************************************************************
  * @file    ys32md211_vrefbuf.h
  * @author  YSPRING Application Team
  * @version V1.0.1
  * @date    2025.02.15
  * @brief   This file contains all the functions prototypes for the VREFBUF 
  *          firmware library.
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __YS32MD211_VREFBUF_H
#define __YS32MD211_VREFBUF_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "ys32md211.h"


/** @addtogroup YS32MD211_StdPeriph_Driver
  * @{
  */

/** @addtogroup VREFBUF
  * @{
  */

/* Exported types ------------------------------------------------------------*/

typedef struct
{
  uint32_t vref_latency;		
  uint32_t vref_tmp;
  uint32_t vref_pllmull;
  uint32_t vref_pllsource;
  uint32_t vref_hsiClk;	
  uint32_t vref_hsiDiv;		
  uint32_t vref_hclk;		
  uint32_t vref_pclk;		
}Vref_ClocksTypeDef;	
  
/** @defgroup VREFBUF CONFIG 
  * @{
  */
#define VREFBUF_BUFV_1d2          VREFBUF_CSR_BUFV_SEL_V1_2
#define VREFBUF_BUFV_2d0          VREFBUF_CSR_BUFV_SEL_V2_0
#define VREFBUF_BUFV_2d5          VREFBUF_CSR_BUFV_SEL_V2_5
#define IS_VREFBUF_BUFV_CONFIG(BUFV_CFG) (((ADC_CFG) == VREFBUF_BUFV_1d2) || \
                                          ((ADC_CFG) == VREFBUF_BUFV_2d0) || \
                                          ((ADC_CFG) == VREFBUF_BUFV_2d5))	


#define VREFBUF_ADC_VREF          VREFBUF_CSR_ADC1_VREF_SEL_VREF
#define VREFBUF_ADC_VCC           VREFBUF_CSR_ADC1_VREF_SEL_VCC
#define VREFBUF_ADC_VREFBUF       VREFBUF_CSR_ADC1_VREF_SEL_VREFINT
#define IS_VREFBUF_ADC_CONFIG(ADC_CFG) (((ADC_CFG) == VREFBUF_ADC_VREF) || \
                                        ((ADC_CFG) == VREFBUF_ADC_VCC)  || \
                                        ((ADC_CFG) == VREFBUF_ADC_VREFBUF))
                            
#define IS_VREFBUF_TRIM_VALUE(VALUE) ((VALUE) <= 0x7)
/**
  * @}
  */

/* Exported functions ------------------------------------------------------- */ 
void VREFBUF_Cmd(FunctionalState NewState);
void VREFBUF_Output_Config(uint32_t BufvConfig);
void VREFBUF_ADC_Config(uint32_t VrefConfig);
void VREFBUF_Trim(uint32_t Value);
  
#ifdef __cplusplus
}
#endif

#endif /* __YS32MD211_VREFBUF_H */

/**
  * @}
  */

/**
  * @}
  */
