clock.h
Go to the documentation of this file.
1 /********************************************************************************************************
2  * @file clock.h
3  *
4  * @brief This is the header file for TLSR8258
5  *
6  * @author Driver Group
7  * @date May 8, 2018
8  *
9  * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd.
10  * All rights reserved.
11  *
12  * The information contained herein is confidential property of Telink
13  * Semiconductor (Shanghai) Co., Ltd. and is available under the terms
14  * of Commercial License Agreement between Telink Semiconductor (Shanghai)
15  * Co., Ltd. and the licensee or the terms described here-in. This heading
16  * MUST NOT be removed from this file.
17  *
18  * Licensees are granted free, non-transferable use of the information in this
19  * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
20  * @par History:
21  * 1.initial release(DEC. 26 2018)
22  *
23  * @version A001
24  *
25  *******************************************************************************************************/
26 
27 #pragma once
28 
29 
30 #include "compiler.h"
31 #include "register.h"
32 
33 
34 #define _ASM_NOP_ asm("tnop")
35 
39 #define CLOCK_DLY_1_CYC _ASM_NOP_
40 #define CLOCK_DLY_2_CYC _ASM_NOP_;_ASM_NOP_
41 #define CLOCK_DLY_3_CYC _ASM_NOP_;_ASM_NOP_;_ASM_NOP_
42 #define CLOCK_DLY_4_CYC _ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_
43 #define CLOCK_DLY_5_CYC _ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_
44 #define CLOCK_DLY_6_CYC _ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_
45 #define CLOCK_DLY_7_CYC _ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_
46 #define CLOCK_DLY_8_CYC _ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_
47 #define CLOCK_DLY_9_CYC _ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_
48 #define CLOCK_DLY_10_CYC _ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_;_ASM_NOP_
49 
53 #ifndef SYSCLK_RC_CLOCK_EN
54 #define SYSCLK_RC_CLOCK_EN 0
55 #endif
56 
57 extern unsigned char system_clk_type;
58 
62 typedef enum{
68 
70 
75 
80 typedef enum{
84 
90 void clock_init(SYS_CLK_TypeDef SYS_CLK);
91 
98 static inline int clock_get_system_clk(void)
99 {
100  return system_clk_type;
101 }
102 
109 
115 void rc_24m_cal (void);
116 
122 void rc_48m_cal (void);
123 
129 void rc_32k_cal (void);
130 
136 void doubler_calibration(void);
137 
138 
unsigned char system_clk_type
Definition: clock.h:66
Definition: clock.h:72
void doubler_calibration(void)
This function performs to calibration the source clock.
Definition: clock.h:65
void rc_48m_cal(void)
This function performs to select 48M RC as the system clock source.
Definition: clock.h:71
Definition: clock.h:67
static int clock_get_system_clk(void)
This function to get the system clock source.
Definition: clock.h:98
Definition: clock.h:81
SYS_CLK_TypeDef
system clock type.
Definition: clock.h:62
void rc_32k_cal(void)
This function performs to select 32K as the system clock source.
void clock_32k_init(CLK_32K_TypeDef src)
This function serves to set 32k clock source.
CLK_32K_TypeDef
32K clock type.
Definition: clock.h:80
Definition: clock.h:64
Definition: clock.h:82
void rc_24m_cal(void)
This function performs to select 24M as the system clock source.
Definition: clock.h:63
Definition: clock.h:73
Definition: clock.h:69
void clock_init(SYS_CLK_TypeDef SYS_CLK)
This function to select the system clock source.