/**
******************************************************************************
* @file xl_clm.c
* @author kirk.gong
* @version 4.5.2
* @date Fri Mar 26 17:29:12 2021
* @brief This file provide function about CLM firmware program
******************************************************************************
* @attention
*
* 2019 by Chipways Communications,Inc. All Rights Reserved.
* This software is supplied under the terms of a license
* agreement or non-disclosure agreement with Chipways.
* Passing on and copying of this document,and communication
* of its contents is not permitted without prior written
* authorization.
*
*
© COPYRIGHT 2019 Chipways
******************************************************************************
*/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
/* Includes ---------------------------------------------------------------*/
#include "xl_clm.h"
/** @addtogroup XL6600_StdPeriph_Driver
* @{
*/
/** @defgroup CLM Module
* @brief CLM Driver Modules Library
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/** @defgroup CLM_Private_Functions
* @{
*/
/**
* @brief CLM³õʼ»¯
* @param CLMx: ÊäÈë¿ÉÓõÄCLMÍâÉè
* @param CLM_InitStruct: CLM_InitTypeDefÀàÐ͵ÄÖ¸Õ룬°üº¬ÁËCLMÍâÉèµÄÉèÖÃÐÅÏ¢¡£
* @retval None
*/
uint8_t CLM_Init(CLM_Type* CLMx, const CLM_InitTypeDef *CLM_InitStruct)
{
if(CLM_InitStruct->CLM_SAMPLE_CLOCK == CLM_SCLK_IRC_CLK)
{
CLMx->CTRL |= CLM_CTRL_SCLK_SEL_MASK;
}
else
{
CLMx->CTRL &= (~CLM_CTRL_SCLK_SEL_MASK);
}
CLMx->CLML = CLM_InitStruct->CLM_CLML;
CLMx->CLMH = CLM_InitStruct->CLM_CLMH;
return 1;
}
/**
* @brief CLMʹÄÜ
* @param CLMx: ÊäÈë¿ÉÓõÄCLMÍâÉè¡£
* @retval None
*/
void CLM_EnableCmd(CLM_Type* CLMx)
{
CLMx->CTRL |= (uint16_t)(0x01u & CLM_CTRL_CLMEN_MASK);
CLMx->CTRL |= (uint16_t)(0xA5u & CLM_CTRL_CLMEN_MASK);
CLMx->CTRL |= (uint16_t)(0x01u & CLM_CTRL_CLMEN_MASK);
}
/**
* @brief CLMÉèÖÃÆµÂÊÆ«ÒÆÏÂÏÞ
* @param CLMx: ÊäÈë¿ÉÓõÄCLMÍâÉè¡£
* @param value: ÊäÈëÆµÂÊÆ«ÒÆÏÂÏÞ
* @retval None
*/
void CLM_Set_CLML(CLM_Type* CLMx, uint16_t value)
{
CLMx->CLML = value;
}
/**
* @brief CLMÉèÖÃÆµÂÊÆ«ÒÆÉÏÏÞ
* @param CLMx: ÊäÈë¿ÉÓõÄCLMÍâÉè¡£
* @param value: ÊäÈëÆµÂÊÆ«ÒÆÉÏÏÞ
* @retval None
*/
void CLM_Set_CLMH(CLM_Type* CLMx, uint16_t value)
{
CLMx->CLMH = value;
}
/**
* @brief CLM»ñÈ¡¸´Î»±êÖ¾
* @param CLMx: ÊäÈë¿ÉÓõÄCLMÍâÉè¡£
* @retval ¸´Î»×´Ì¬(SET or RESET)
*/
uint8_t CLM_GetResetFlag(const CLM_Type* CLMx)
{
return (uint8_t)CLMx->RSTF & CLM_RSTF_RSTF_MASK;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */