/**
  **********************************************************************************
  * @file    cpm_hal.c
  * @author  Product application department
  * @version V1.0
  * @date    2020.03.18
  * @brief   CPM模块HAL层驱动.
  * @note 这个文件为应用层提供了操作CPM的接口:
  *     - 设置系统时钟接口.
  *     - 设置USB时钟接口.
  *     - 获取IP、EFM、SYSTEM的时钟接口.
  *
  @verbatim
  ===================================================================================
                                  ##### 更新 #####
  ===================================================================================
  [..] 更新时间:
  [..] 更新人:
  [..] 更新内容:
        1. nothing.
  @endverbatim
  */
#include "cpm_hal.h"
#include "updata.h"
#include "libSwithOSC500MHz.h"

#define SysSsiConfigure  (*(void (*)(uint32_t,uint32_t,uint32_t,uint32_t,uint32_t,uint32_t))(((uint32_t *)(0x2001f001))))
/*** 全局变量定义 ***************************************************************/
/** @
  * @{volatile
  */
/** @ 
  * @}
  */
/** @ 
  * @{static
  */
static uint8_t g_OSC500M_Flg = FALSE;
/** @ 
  * @}
  */
/*** 常量定义 *******************************************************************/
/** @
  * @{const
  */
/** @ 
  * @}
  */

/*** 函数定义 *******************************************************************/


/**
 * @brief 设置系统时钟
 *
 * @param[in] CPM_SYSCLKSource 配置的系统时钟源
 * @param[in] sys_clk_trim 系统时钟源Trim,注意只能Trim内部400M晶振
 * @param[in] core_div 系统时钟源分频系数，取值范围【0x0~0xf】
 * @param[in] sys_div 系统时钟源分频系数，取值范围【0x00~0xff】
 * @param[in] ips_div IPS时钟源分频系数，取值范围【0x00~0x0f】
 * @return @ref CPM_ErrCodeTypeDef
 */
void HAL_CPM_SYSCLKConfig(CPM_ClkInitTypeDef *pClkInit)
{
	uint32_t efcr_reg;

 
	
	//配置系统时钟
	if(HAL_SYSCLK_OSC8M == pClkInit->SysClkSource)
	{
		DRV_CPM_SystemClkOSC8MSelect();
	}
	else if(HAL_SYSCLK_OSC400M == pClkInit->SysClkSource)
	{
	   DRV_CPM_SystemClkOSC400MSelect();
	}
	else if(HAL_SYSCLK_OSC500M == pClkInit->SysClkSource)
	{  
		  HAL_StatusTypeDef st;
		
			st = HAL_CPM_SwitchOSC500MHz();  
			if (st == HAL_ERROR)//芯片不支持跑500M，恢复到400M
			{
				pClkInit->SysClkSource = HAL_SYSCLK_OSC400M;
			}
	    DRV_CPM_SystemClkOSC400MSelect();
	}
	else if(HAL_SYSCLK_OSCUSBPHU480M == pClkInit->SysClkSource)
	{
	   DRV_CPM_SystemClkOSC480MSelect();    	
	}
	else if(HAL_SYSCLK_OSCEXT == pClkInit->SysClkSource)
	{
		DRV_CPM_SystemClkOSCEXTSelect();
	}

	//配置IPS时钟（分频系数不可以为0）
	if(CLK_DIV_1 == pClkInit->IpsClkDiv)
	{
		DRV_CPM_SetIpsClkDiv(pClkInit->IpsClkDiv+1);
	}
	else
	{
		DRV_CPM_SetIpsClkDiv(pClkInit->IpsClkDiv);
	}
	
	if((CLK_DIV_1 == pClkInit->CoreClkDiv)&&(CLK_DIV_1 == pClkInit->SysClkDiv))
	{
	 DRV_CPM_SetSystemClkDiv(pClkInit->SysClkDiv+1);
	}
	else
  {
	 DRV_CPM_SetSystemClkDiv(pClkInit->SysClkDiv);
	
	}
	
	 
	DRV_CPM_SetCoreClkDiv(pClkInit->CoreClkDiv);

	
	//获取CPU核时钟
	if (pClkInit->SysClkSource == CPM_SYSCLK_OSC500M)
	{
		g_OSC500M_Flg = TRUE;
		g_core_clk = DRV_CPM_GetCOREClHz(TRUE);
	}
	else 
	{
		g_OSC500M_Flg = FALSE;
		//获取CPU核时钟
		g_core_clk = DRV_CPM_GetCOREClHz(FALSE);
	}
	
	//获取系统时钟
	g_sys_clk = DRV_CPM_GetSYSClHz();
	
	//获取ips时钟
	g_ips_clk = DRV_CPM_GetIPSClHz();	
	
	
	if((g_sys_clk>=DRV_SYS_OSC_CLK_200M)&&(CLK_DIV_1 == pClkInit->SdramClkDiv))
	{
		
	  DRV_CPM_SetSdramClkDiv(pClkInit->SdramClkDiv+1);
	
	}
	else
	{
	
	  DRV_CPM_SetSdramClkDiv(pClkInit->SdramClkDiv);
	}
  g_sdram_clk = DRV_CPM_GetSDRAMClHz();
 
}

/*** 函数定义 *******************************************************************/
/**
 * @brief 获取系统时钟
 *
 */
void HAL_CPM_GETCLCK(void)
{
	//获取CPU核时钟
	if (g_OSC500M_Flg == TRUE)
	{
		g_core_clk = DRV_CPM_GetCOREClHz(TRUE);
	}
	else 
	{
		//获取CPU核时钟
		g_core_clk = DRV_CPM_GetCOREClHz(FALSE);
	}
	
	//获取系统时钟
	g_sys_clk = DRV_CPM_GetSYSClHz();
	
	//获取ips时钟
	g_ips_clk = DRV_CPM_GetIPSClHz();	
	
	//获取sdram时钟 
  g_sdram_clk = DRV_CPM_GetSDRAMClHz();
	
}
/*** 函数定义 *******************************************************************/
/**
 * @brief 设置系统时钟
 *
 * @param[in] CPM_SYSCLKSource 配置的系统时钟源
 * @param[in] sys_clk_trim 系统时钟源Trim,注意只能Trim内部400M晶振
 * @param[in] core_div 系统时钟源分频系数，取值范围【0x0~0xf】
 * @param[in] sys_div 系统时钟源分频系数，取值范围【0x00~0xff】
 * @param[in] ips_div IPS时钟源分频系数，取值范围【0x00~0x0f】
 * @return @ref CPM_ErrCodeTypeDef
 */
void HAL_CPM_SSI_SYSCLKConfig(CPM_ClkInitTypeDef *pClkInit)
{
	uint32_t efcr_reg;

  memcpy(0x2001f000,updata_bin_data,totalbytes);
	//配置系统时钟
	if(HAL_SYSCLK_OSC8M == pClkInit->SysClkSource)
	{
		DRV_CPM_SystemClkOSC8MSelect();
	}
	else if(HAL_SYSCLK_OSC400M == pClkInit->SysClkSource)
	{
	   DRV_CPM_SystemClkOSC400MSelect();
	}
	else if(HAL_SYSCLK_OSC500M == pClkInit->SysClkSource)
	{  
		  HAL_StatusTypeDef st;
		
			st = HAL_CPM_SwitchOSC500MHz();  
			if (st == HAL_ERROR)//芯片不支持跑500M，恢复到400M
			{
				pClkInit->SysClkSource = HAL_SYSCLK_OSC400M;
			}
	    DRV_CPM_SystemClkOSC400MSelect();
	}
	else if(HAL_SYSCLK_OSCUSBPHU480M == pClkInit->SysClkSource)
	{
	   DRV_CPM_SystemClkOSC480MSelect();    	
	}
	else if(HAL_SYSCLK_OSCEXT == pClkInit->SysClkSource)
	{
		DRV_CPM_SystemClkOSCEXTSelect();
	}
	
     
	
	//配置IPS时钟（分频系数不可以为0）
	if(CLK_DIV_1 == pClkInit->IpsClkDiv)
	{
		DRV_CPM_SetIpsClkDiv(pClkInit->IpsClkDiv+1);
	}
	else
	{
		DRV_CPM_SetIpsClkDiv(pClkInit->IpsClkDiv);
	}
	
	if((CLK_DIV_1 == pClkInit->CoreClkDiv)&&(CLK_DIV_1 == pClkInit->SysClkDiv))
	{
	 
		SysSsiConfigure(1, pClkInit->CoreClkDiv+1, pClkInit->SysClkDiv+2, 2, 2, 2);	
	}
	else
  {
	 
		SysSsiConfigure(1,pClkInit->CoreClkDiv+1,pClkInit->SysClkDiv+1,2,2,2);	
	
	}
	

	//获取CPU核时钟
	if (pClkInit->SysClkSource == CPM_SYSCLK_OSC500M)
	{
		g_OSC500M_Flg = TRUE;
		g_core_clk = DRV_CPM_GetCOREClHz(TRUE);
	}
	else 
	{
		g_OSC500M_Flg = FALSE;
		//获取CPU核时钟
		g_core_clk = DRV_CPM_GetCOREClHz(FALSE);
	}
	
	//获取系统时钟
	g_sys_clk = DRV_CPM_GetSYSClHz();
	
	//获取ips时钟
	g_ips_clk = DRV_CPM_GetIPSClHz();	
	
	if((g_sys_clk>=DRV_SYS_OSC_CLK_200M)&&(CLK_DIV_1 == pClkInit->SdramClkDiv))
	{
		
	  DRV_CPM_SetSdramClkDiv(pClkInit->SdramClkDiv+1);
	
	}
	else
	{
	
	  DRV_CPM_SetSdramClkDiv(pClkInit->SdramClkDiv);
	}
  g_sdram_clk = DRV_CPM_GetSDRAMClHz();
 
}
/**
 * @brief 使能、失能模块时钟
 *
 * @param[in] Module_Mask:使能、失能的IP模块
 * @param[in] NewState:模块时钟的新状态
 *   这个参数可以取：ENABLE或者DISABLE
 * @retval NONE
 */
void HAL_CPM_ModuleClkCmd(CPM_ModuleClkIndexTypeDef ModuleClkIdex, FunctionalState NewState)
{
	if (NewState != DISABLE)
	{
		/* Enable the selected  Module clock*/
		DRV_CPM_ModuleClkOn(ModuleClkIdex);
	}
	else
	{
		/* Disable the selected IP Module clock*/
		DRV_CPM_ModuleClkOff(ModuleClkIdex);
	}
}

/**
 * @brief 获取IP、EFM、SYSTEM的时钟
 *
 * @param[in] CLKSourceFlg 时钟源标志,取值HAL_SYSCLKSOURCE_FLAG、HAL_IPSCLKSOURCE_FLAG或HAL_EFMCLKSOURCE_FLAG
 * @return @ref 时钟源的时钟，单位Hz
 */
uint32_t HAL_CPM_GetClocksFreq(uint8_t ClkSourceFlg)
{
	int32_t clock_freq = 0;

	switch (ClkSourceFlg)
	{
	    case HAL_SYSCLKSOURCE_FLAG:
	    {
	    	/*get system clock */
	    	clock_freq = DRV_CPM_GetSYSClHz();
	    	break;
	    }
	    case HAL_IPSCLKSOURCE_FLAG:
	    {
	    	/*get ips clock */
	    	clock_freq = DRV_CPM_GetIPSClHz();
	    	break;
	    }
	    case HAL_EFMCLKSOURCE_FLAG:
	    {
	    	/*get efm clock */
	    	clock_freq = DRV_CPM_GetEFMClHz();
	    	break;
	    }
	    default: 
	    {
				/*system clock */
	    	clock_freq = DRV_CPM_GetSYSClHz();
	        break;
	    }
	}
	return (clock_freq);
}


/**
 * @brief 设置IPS、EPT、CLKOUT、EFM、SYSTEM的时钟分频
 *
 * @param[in] CLKSourceFlg: 时钟源标志。
 * @param[in] Div:分频系数,分频值等于(Div+1)
 * @retval NONE
 */
void HAL_CPM_SetCLKDiv(CPM_ClkSourceIndexTypeDef ClkSourceIndex, uint8_t Div)
{
	switch (ClkSourceIndex)
	{
	  case HAL_CHIP_SYS_CLK_INDEX_CLKOUT:
	  {
			/*CLKOUT时钟分频*/
			DRV_CPM_SetClkoutClkDiv(Div);
	    break;
	  }
		case HAL_CHIP_SYS_CLK_INDEX_TRACE:
		{
			/*TRACE时钟分频*/
			DRV_CPM_SetTraceClkDiv(Div);
			break;
		}
		case HAL_CHIP_SYS_CLK_INDEX_SYS:
		{
			/*系统时钟分频 */
			DRV_CPM_SetSystemClkDiv(Div);
			break;
		}
		case HAL_CHIP_CORE_CLK_INDEX_SYS:
		{
			/*内核时钟分频 */
			DRV_CPM_SetCoreClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_ARITH:
		{
			/*ARITH时钟分频*/
			DRV_CPM_SetArithClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_AHB3:
		{
			/*AHB3输出时钟分频*/
			DRV_CPM_SetAhb3ClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_IPS:
		{
			/*IPS时钟分频*/
			DRV_CPM_SetIpsClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_TC:
		{
			/*TC时钟分频*/
		  DRV_CPM_SetTcClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_MESH:
		{
			/*MESH时钟分频*/
		  DRV_CPM_SetMeshClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_ADC:
		{
			/*ADC时钟分频*/
		  DRV_CPM_SetAdcClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_MCC_ADR:
		{
			/*MCC_ADR时钟分频*/
		  DRV_CPM_SetMccAdrClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_MCC:
		{
			/*MCC时钟分频*/
		  DRV_CPM_SetMccClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_SDRAM2LCD:
		{
			/*系统时钟分频 */
			DRV_CPM_SetSdram2lcdClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_SDRAM_SM:
		{
			/*ARITH时钟分频*/
			DRV_CPM_SetSdram_smClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_SDRAM:
		{
			/*AHB3输出时钟分频*/
			DRV_CPM_SetSdramClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_CLCD:
		{
			/*IPS时钟分频*/
			DRV_CPM_SetClcdClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_SD_HOST:
		{
			/*TC时钟分频*/
		  	DRV_CPM_SetSd_hostClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_DCMI_SENSOR:
		{
			/*MESH时钟分频*/
		  	DRV_CPM_SetDcmi_sensorClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_DCMI_PIX:
		{
			/*ADC时钟分频*/
		  	DRV_CPM_SetDcmi_pixClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_MIPI_SAMPLE:
		{
			/*MCC_ADR时钟分频*/
		  	DRV_CPM_SetMipi_sampleClkDiv(Div);
			break;
		}
		case HAL_CHIP_PERIPHERAL_CLK_INDEX_DMA2D_SRAM:
		{
			/*MCC时钟分频*/
		  	DRV_CPM_SetDma2d_sramClkDiv(Div);
			break;
		}
		default:
		{
			break;
		}
	}
}

void HAL_CPM_VCC5VByPass(void)
{
    DRV_CPM_VccCoreTestModeKeySet();
    
    _CPM_SET_TRIM_EN;
    _CPM_V33_SW_DIS;
    
}



/**
 * @brief CPM中断处理函数
 *
 * @param[in] 
 * - NONE
 * @retval
 * - NONE
 */
void HAL_CPM_IRQHandler(void)
{
	if(_cpm_get_usb_det_wakeup_src_int_flag)
	{
		_cpm_clr_usb_det_wakeup_src_int_flag;
#ifdef HAL_CPM_DEBUG
		printf("usb_det!\r\n");
#endif
	}
	
	if(_cpm_get_wake_wakeup_src_int_flag)
	{
		_cpm_clr_wake_wakeup_src_int_flag;
#ifdef HAL_CPM_DEBUG
		printf("wake!\r\n");
#endif
	}
	
	if(_cpm_get_pci_det_wakeup_src_int_flag)
	{
		_cpm_clr_pci_det_wakeup_src_int_flag;
#ifdef HAL_CPM_DEBUG
		printf("pci_det!\r\n");
#endif
	}
	
	if(_cpm_get_pci_atimer_wakeup_src_int_flag)
	{
		_cpm_clr_pci_atimer_wakeup_src_int_flag;
#ifdef HAL_CPM_DEBUG
		printf("pci_atimer!\r\n");
#endif
	}
	
	if(_cpm_get_pad_ss3_wakeup_src_int_flag)
	{
		_cpm_clr_pad_ss3_wakeup_src_int_flag;
#ifdef HAL_CPM_DEBUG
		printf("pad_ss3!\r\n");
#endif
	}
	
	if(_cpm_get_s2m_wakeup_src_int_flag)
	{
		_cpm_clr_s2m_wakeup_src_int_flag;
#ifdef HAL_CPM_DEBUG
		printf("s2m!\r\n");
#endif
	}
}

/**
 * @brief CPM 唤醒中断源初始化
 *
 * @param[in] CPM_PadWakeupIndexTypeDef :CPM唤醒源选择
 * @param[in] NewState :是否使能中断
 * @retval
  * - NONE
 */
void HAL_CPM_WakeupInit(CPM_PadWakeupIndexTypeDef Src, FunctionalState NewState)
{
	switch(Src)
	{
		case HAL_PAD_WAKEUP_INDEX_USBDET:
			_cpm_set_usb_det_wakeup_src_en;
		  if(NewState == ENABLE)
			{
				NVIC_Init(3, 3, PCI_IRQn, 2);
				_cpm_set_usb_det_wakeup_src_int_en;
			}
			break;
			
		  case HAL_PAD_WAKEUP_INDEX_WAKE:
			_cpm_set_wake_wakeup_src_en;
		  if(NewState == ENABLE)
			{
				NVIC_Init(3, 3, PCI_IRQn, 2);
				_cpm_set_wake_wakeup_src_int_en;
			}
			break;		

		case HAL_PAD_WAKEUP_INDEX_PCI_DET:
			_cpm_set_pci_det_wakeup_src_en;
		  if(NewState == ENABLE)
			{
				NVIC_Init(3, 3, PCI_IRQn, 2);
				_cpm_set_pci_det_wakeup_src_int_en;
			}
			break;

		case HAL_PAD_WAKEUP_INDEX_PCI_ATIMER:
			_cpm_set_pci_atimer_wakeup_src_en;
		  if(NewState == ENABLE)
			{
				NVIC_Init(3, 3, PCI_IRQn, 2);
				_cpm_set_pci_atimer_wakeup_src_int_en;
			}
			break;

		case HAL_PAD_WAKEUP_INDEX_PAD_SS3:
			_cpm_set_pad_ss3_wakeup_src_en;
		  if(NewState == ENABLE)
			{
				NVIC_Init(3, 3, PCI_IRQn, 2);
				_cpm_set_pad_ss3_wakeup_src_int_en;
			}
			break;

		case HAL_PAD_WAKEUP_INDEX_S2M:
			_cpm_set_s2m_wakeup_src_en;
		  if(NewState == ENABLE)
			{
				NVIC_Init(3, 3, PCI_IRQn, 2);
				_cpm_set_s2m_wakeup_src_int_en;
			}
			break;

		default :
			break;
	}
}

/**
 * @brief CPM 唤醒中断源反初始化
 *
 * @param[in] hWkp :CPM handler 结构体
 *
 * @retval
  * - NONE
 */
void HAL_CPM_WakeupDeInit(void)
{
	_cpm_clr_wakeup_src;
}

/**
 * @brief CPM 唤醒中断源触发检测
 *
 * @param[in]
 * - NONE
 * @retval 
 *- 是CPM_PadWakeupIndexTypeDef枚举类型的组合
 *
 */
uint8_t HAL_CPM_WakeupFlagDet(void)
{
	uint8_t tmp = 0;
	
	if(_cpm_get_usb_det_wakeup_src_int_flag)
	{
		tmp |= HAL_PAD_WAKEUP_INDEX_USBDET;
	}
	
	if(_cpm_get_wake_wakeup_src_int_flag)
	{
		tmp |= HAL_PAD_WAKEUP_INDEX_WAKE;
	}
	
	if(_cpm_get_pci_det_wakeup_src_int_flag)
	{
		tmp |= HAL_PAD_WAKEUP_INDEX_PCI_DET;
	}
	
	if(_cpm_get_pci_atimer_wakeup_src_int_flag)
	{
		tmp |= HAL_PAD_WAKEUP_INDEX_PCI_ATIMER;
	}
	
	if(_cpm_get_pad_ss3_wakeup_src_int_flag)
	{
		tmp |= HAL_PAD_WAKEUP_INDEX_PAD_SS3;
	}
	
	if(_cpm_get_s2m_wakeup_src_int_flag)
	{
		tmp |= HAL_PAD_WAKEUP_INDEX_S2M;
	}
	
	return tmp;
}

/**
 * @brief CPM 卡模块上电
 *
 * @param[in] vcc 模块输出电压
 * -CARD_1V8：1.8V
 * -CARD_3V0：3V
 * -CARD_3V3：3.3V
 * -CARD_5V0：5V
 * - NONE
 * @return NONE
 *
 */
void HAL_CPM_CardPowerOn(CardVCC_TypeDef vcc)
{
	
	_cpm_set_vcard1_interface_isolation_en;
	
	_cpm_card1_ldo_poweroff;
	
	/*enable USI2 card LDO,vcc output*/
	if(vcc == CARD_1V8)
	{
	  _cpm_card1_ldo_votage_out_config(CPM_SLPCFGR_CARD1_LDO_VOTAGE_OUT_1V8);
	}
	else if(vcc == CARD_3V0)
	{
		_cpm_card1_ldo_votage_out_config(CPM_SLPCFGR_CARD1_LDO_VOTAGE_OUT_3V0);
	}
	else if(vcc == CARD_3V3)
	{
		_cpm_card1_ldo_votage_out_config(CPM_SLPCFGR_CARD1_LDO_VOTAGE_OUT_3V3);
	}
	else
	{
		_cpm_card1_ldo_votage_out_config(CPM_SLPCFGR_CARD1_LDO_VOTAGE_OUT_5V0);
	}
	
	_cpm_card1_ldo_poweron;
	
	/*disable USI3 I/O isolation*/
	_cpm_set_vcard1_interface_isolation_dis;
	
	//等待card vcc输出稳定
#if 0
	while(!_cpm_get_vcc_card1_ready_flag);
#else
	DelayMS(10);
	
	//卡短路等情况导致没有稳定输出VCC则下电
	if(!_cpm_get_vcc_card1_ready_flag)
	{
			_cpm_set_vcard1_interface_isolation_en;

			_cpm_card1_ldo_poweroff;
	}
#endif
}

/**
 * @brief CPM 关闭卡模块电源
 *
 * @param[in]
 * - NONE
 * @return NONE
 *
 */
void HAL_CPM_CardPowerOff(void)
{
	_cpm_set_vcard1_interface_isolation_en;

	_cpm_card1_ldo_poweroff;
	
		//等待card ldo电源释放完毕
	DelayMS(5);
}

/**
 * @brief CPM Trim card的输出电压
 *
 * @param[in]1
 * - NONE
 * @return NONE
 *
 */
void HAL_CPM_TrimCardVoltage(uint8_t trimValue)
{
	//写Key
	DRV_CPM_VccCoreTestModeKeySet();
	//Enable CPU to Overwrite the Trimmed Value for VREF
	_cpm_set_overwrite_vccvtrimr_trim_en;
	
	//设置trim值
	_cpm_set_vref_trim_value(trimValue);
	
	_cpm_set_vref_trim_en;
	
	_cpm_load_vref_trim_value;
}

/**
 * @brief software por 复位
 *
 * @param[in]
 * - NONE
 * @return NONE
 *
 */
void HAL_CPM_PorReset(void)
{
    DRV_CPM_PorReset();
}



