summaryrefslogtreecommitdiffstats
path: root/libopencm3/include/libopencm3/stm32/f0/crs.h
blob: b65610ca66c57915950f1b1938b68385ec820fd4 (plain)
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
/** @defgroup CRS_defines CRS Defines
 *
 * @brief <b>Defined Constants and Types for the STM32F0xx Clock Recovery</b>
 *
 * @ingroup STM32F0xx_defines
 *
 * @version 1.0.0
 *
 * @date 5 Feb 2014
 *
 * LGPL License Terms @ref lgpl_license
 */
/*
 * This file is part of the libopencm3 project.
 *
 * Copyright (C) 2014 Frantisek Burian <BuFran@seznam.cz>
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LIBOPENCM3_CRS_H
#define LIBOPENCM3_CRS_H
/**@{*/

/*****************************************************************************/
/* Module definitions                                                        */
/*****************************************************************************/

#define CRS				CRS_BASE

/*****************************************************************************/
/* Register definitions                                                      */
/*****************************************************************************/

#define CRS_CR				MMIO32(CRS_BASE + 0x00)
#define CRS_CFGR			MMIO32(CRS_BASE + 0x04)
#define CRS_ISR				MMIO32(CRS_BASE + 0x08)
#define CRS_ICR				MMIO32(CRS_BASE + 0x0c)

/*****************************************************************************/
/* Register values                                                           */
/*****************************************************************************/

/* CEC_CR Values ------------------------------------------------------------*/

#define CRS_CR_TRIM_SHIFT		8
#define CRS_CR_TRIM			(0x3F << CRS_CR_TRIM_SHIFT)

#define CRS_CR_SWSYNC			(1 << 7)
#define CRS_CR_AUTOTRIMEN		(1 << 6)
#define CRS_CR_CEN			(1 << 5)
#define CRS_CR_ESYNCIE			(1 << 3)
#define CRS_CR_ERRIE			(1 << 2)
#define CRS_CR_SYNCWARNIE		(1 << 1)
#define CRS_CR_SYNCOKIE			(1 << 0)

/* CEC_CFGR Values ----------------------------------------------------------*/

#define CRS_CFGR_SYNCPOL		(1 << 31)

#define CRS_CFGR_SYNCSRC_SHIFT		28
#define CRS_CFGR_SYNCSRC		(3 << CRS_CFGR_SYNCSRC_SHIFT)
#define CRS_CFGR_SYNCSRC_GPIO		(0 << CRS_CFGR_SYNCSRC_SHIFT)
#define CRS_CFGR_SYNCSRC_LSE		(1 << CRS_CFGR_SYNCSRC_SHIFT)
#define CRS_CFGR_SYNCSRC_USB_SOF	(2 << CRS_CFGR_SYNCSRC_SHIFT)

#define CRS_CFGR_SYNCDIV_SHIFT		24
#define CRS_CFGR_SYNCDIV		(7 << CRS_CFGR_SYNCDIV_SHIFT)
#define CRS_CFGR_SYNCDIV_NODIV		(0 << CRS_CFGR_SYNCDIV_SHIFT)
#define CRS_CFGR_SYNCDIV_DIV2		(1 << CRS_CFGR_SYNCDIV_SHIFT)
#define CRS_CFGR_SYNCDIV_DIV4		(2 << CRS_CFGR_SYNCDIV_SHIFT)
#define CRS_CFGR_SYNCDIV_DIV8		(3 << CRS_CFGR_SYNCDIV_SHIFT)
#define CRS_CFGR_SYNCDIV_DIV16		(4 << CRS_CFGR_SYNCDIV_SHIFT)
#define CRS_CFGR_SYNCDIV_DIV32		(5 << CRS_CFGR_SYNCDIV_SHIFT)
#define CRS_CFGR_SYNCDIV_DIV64		(6 << CRS_CFGR_SYNCDIV_SHIFT)
#define CRS_CFGR_SYNCDIV_DIV128		(7 << CRS_CFGR_SYNCDIV_SHIFT)

#define CRS_CFGR_FELIM_SHIFT		16
#define CRS_CFGR_FELIM			(0xFF << CRS_CFGR_FELIM_SHIFT)
#define CRS_CFGR_FELIM_VAL(x)		((x) << CRS_CFGR_FELIM_SHIFT)

#define CRS_CFGR_RELOAD_SHIFT		0
#define CRS_CFGR_RELOAD			(0xFFFF << CRS_CFGR_RELOAD_SHIFT)
#define CRS_CFGR_RELOAD_VAL(x)		((x) << CRS_CFGR_RELOAD_SHIFT)

/* CEC_ISR Values -----------------------------------------------------------*/

#define CRS_ISR_FECAP_SHIFT		16
#define CRS_ISR_FECAP			(0xFFFF << CRS_ISR_FECAP_SHIFT)

#define CRS_ISR_FEDIR			(1 << 15)
#define CRS_ISR_TRIMOVF			(1 << 10)
#define CRS_ISR_SYNCMISS		(1 << 9)
#define CRS_ISR_SYNCERR			(1 << 8)
#define CRS_ISR_ESYNCF			(1 << 3)
#define CRS_ISR_ERRF			(1 << 2)
#define CRS_ISR_SYNCWARNF		(1 << 1)
#define CRS_ISR_SYNCOOKF		(1 << 0)

/* CEC_ICR Values -----------------------------------------------------------*/

#define CRS_ICR_ESYNCC			(1 << 3)
#define CRS_ICR_ERRC			(1 << 2)
#define CRS_ICR_SYNCWARNC		(1 << 1)
#define CRS_ICR_SYNCOKC			(1 << 0)

/*****************************************************************************/
/* API definitions                                                           */
/*****************************************************************************/

/*****************************************************************************/
/* API Functions                                                             */
/*****************************************************************************/

BEGIN_DECLS

END_DECLS
/**@}*/

#endif