tao_z
2022-05-25 1044ba0d2286698d0da28112bffc0f114bef2134
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
  ******************************************************************************
  * @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.
  *
  * <h2><center>&copy; COPYRIGHT 2019 Chipways</center></h2>
  ******************************************************************************
  */
#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 */