Contiki 3.x
sys-ctrl.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 /**
32  * \addtogroup cc2538
33  * @{
34  *
35  * \defgroup cc2538-sys-ctrl cc2538 System Control
36  *
37  * Driver for the cc2538 System Control Module
38  * @{
39  *
40  * \file
41  * Header file for the cc2538 System Control driver
42  */
43 #ifndef SYS_CTRL_H_
44 #define SYS_CTRL_H_
45 /*---------------------------------------------------------------------------*/
46 /** \name SysCtrl Constants, used by the SYS_DIV and IO_DIV bits of the
47  * SYS_CTRL_CLOCK_CTRL register
48  * @{
49  */
50 #define SYS_CTRL_32MHZ 32000000
51 #define SYS_CTRL_16MHZ 16000000
52 #define SYS_CTRL_8MHZ 8000000
53 #define SYS_CTRL_4MHZ 4000000
54 #define SYS_CTRL_2MHZ 2000000
55 #define SYS_CTRL_1MHZ 1000000
56 #define SYS_CTRL_500KHZ 500000
57 #define SYS_CTRL_250KHZ 250000
58 /** @} */
59 /*---------------------------------------------------------------------------*/
60 /** \name Definitions of Sys Ctrl registers
61  * @{
62  */
63 #define SYS_CTRL_CLOCK_CTRL 0x400D2000 /**< Clock control register */
64 #define SYS_CTRL_CLOCK_STA 0x400D2004 /**< Clock status register */
65 #define SYS_CTRL_RCGCGPT 0x400D2008 /**< GPT[3:0] clocks - active mode */
66 #define SYS_CTRL_SCGCGPT 0x400D200C /**< GPT[3:0] clocks - sleep mode */
67 #define SYS_CTRL_DCGCGPT 0x400D2010 /**< GPT[3:0] clocks - PM0 */
68 #define SYS_CTRL_SRGPT 0x400D2014 /**< GPT[3:0] reset control */
69 #define SYS_CTRL_RCGCSSI 0x400D2018 /**< SSI[1:0] clocks - active mode */
70 #define SYS_CTRL_SCGCSSI 0x400D201C /**< SSI[1:0] clocks - sleep mode */
71 #define SYS_CTRL_DCGCSSI 0x400D2020 /**< SSI[1:0] clocks - PM0 mode */
72 #define SYS_CTRL_SRSSI 0x400D2024 /**< SSI[1:0] reset control */
73 #define SYS_CTRL_RCGCUART 0x400D2028 /**< UART[1:0] clocks - active mode */
74 #define SYS_CTRL_SCGCUART 0x400D202C /**< UART[1:0] clocks - sleep mode */
75 #define SYS_CTRL_DCGCUART 0x400D2030 /**< UART[1:0] clocks - PM0 */
76 #define SYS_CTRL_SRUART 0x400D2034 /**< UART[1:0] reset control */
77 #define SYS_CTRL_RCGCI2C 0x400D2038 /**< I2C clocks - active mode */
78 #define SYS_CTRL_SCGCI2C 0x400D203C /**< I2C clocks - sleep mode */
79 #define SYS_CTRL_DCGCI2C 0x400D2040 /**< I2C clocks - PM0 */
80 #define SYS_CTRL_SRI2C 0x400D2044 /**< I2C clocks - reset control */
81 #define SYS_CTRL_RCGCSEC 0x400D2048 /**< Sec Mod clocks - active mode */
82 #define SYS_CTRL_SCGCSEC 0x400D204C /**< Sec Mod clocks - sleep mode */
83 #define SYS_CTRL_DCGCSEC 0x400D2050 /**< Sec Mod clocks - PM0 */
84 #define SYS_CTRL_SRSEC 0x400D2054 /**< Sec Mod reset control */
85 #define SYS_CTRL_PMCTL 0x400D2058 /**< Power Mode Control */
86 #define SYS_CTRL_SRCRC 0x400D205C /**< CRC on state retention */
87 #define SYS_CTRL_PWRDBG 0x400D2074 /**< Power debug register */
88 #define SYS_CTRL_CLD 0x400D2080 /**< clock loss detection feature */
89 #define SYS_CTRL_IWE 0x400D2094 /**< interrupt wake-up. */
90 #define SYS_CTRL_I_MAP 0x400D2098 /**< Interrupt map select */
91 #define SYS_CTRL_RCGCRFC 0x400D20A8 /**< RF Core clocks - active mode */
92 #define SYS_CTRL_SCGCRFC 0x400D20AC /**< RF Core clocks - Sleep mode */
93 #define SYS_CTRL_DCGCRFC 0x400D20B0 /**< RF Core clocks - PM0 */
94 #define SYS_CTRL_EMUOVR 0x400D20B4 /**< Emulator override */
95 /** @} */
96 /*---------------------------------------------------------------------------*/
97 /** \name SYS_CTRL_CLOCK_CTRL register bit masks
98  * @{
99  */
100 #define SYS_CTRL_CLOCK_CTRL_OSC32K_CALDIS 0x02000000
101 #define SYS_CTRL_CLOCK_CTRL_OSC32K 0x01000000
102 #define SYS_CTRL_CLOCK_CTRL_AMP_DET 0x00200000
103 #define SYS_CTRL_CLOCK_CTRL_OSC_PD 0x00020000
104 #define SYS_CTRL_CLOCK_CTRL_OSC 0x00010000
105 #define SYS_CTRL_CLOCK_CTRL_IO_DIV 0x00000700
106 #define SYS_CTRL_CLOCK_CTRL_SYS_DIV 0x00000007
107 /** @} */
108 /*---------------------------------------------------------------------------*/
109 /** \name SYS_CTRL_CLOCK_STA register bit masks
110  * @{
111  */
112 #define SYS_CTRL_CLOCK_STA_SYNC_32K 0x04000000
113 #define SYS_CTRL_CLOCK_STA_OSC32K_CALDIS 0x02000000
114 #define SYS_CTRL_CLOCK_STA_OSC32K 0x01000000
115 #define SYS_CTRL_CLOCK_STA_RST 0x00C00000
116 #define SYS_CTRL_CLOCK_STA_SOURCE_CHANGE 0x00100000
117 #define SYS_CTRL_CLOCK_STA_XOSC_STB 0x00080000
118 #define SYS_CTRL_CLOCK_STA_HSOSC_STB 0x00040000
119 #define SYS_CTRL_CLOCK_STA_OSC_PD 0x00020000
120 #define SYS_CTRL_CLOCK_STA_OSC 0x00010000
121 #define SYS_CTRL_CLOCK_STA_IO_DIV 0x00000700
122 #define SYS_CTRL_CLOCK_STA_RTCLK_FREQ 0x00000018
123 #define SYS_CTRL_CLOCK_STA_SYS_DIV 0x00000007
124 /** @} */
125 /*---------------------------------------------------------------------------*/
126 /** \name SYS_CTRL_RCGCGPT register bit masks
127  * @{
128  */
129 #define SYS_CTRL_RCGCGPT_GPT3 0x00000008 /**< GPT3 clock enable, CPU running */
130 #define SYS_CTRL_RCGCGPT_GPT2 0x00000004 /**< GPT2 clock enable, CPU running */
131 #define SYS_CTRL_RCGCGPT_GPT1 0x00000002 /**< GPT1 clock enable, CPU running */
132 #define SYS_CTRL_RCGCGPT_GPT0 0x00000001 /**< GPT0 clock enable, CPU running */
133 /** @} */
134 /*---------------------------------------------------------------------------*/
135 /** \name SYS_CTRL_SCGCGPT register bit masks
136  * @{
137  */
138 #define SYS_CTRL_SCGCGPT_GPT3 0x00000008 /**< GPT3 clock enable, CPU IDLE */
139 #define SYS_CTRL_SCGCGPT_GPT2 0x00000004 /**< GPT2 clock enable, CPU IDLE */
140 #define SYS_CTRL_SCGCGPT_GPT1 0x00000002 /**< GPT1 clock enable, CPU IDLE */
141 #define SYS_CTRL_SCGCGPT_GPT0 0x00000001 /**< GPT0 clock enable, CPU IDLE */
142 /** @} */
143 /*---------------------------------------------------------------------------*/
144 /** \name SYS_CTRL_DCGCGPT register bit masks
145  * @{
146  */
147 #define SYS_CTRL_DCGCGPT_GPT3 0x00000008 /**< GPT3 clock enable, PM0 */
148 #define SYS_CTRL_DCGCGPT_GPT2 0x00000004 /**< GPT2 clock enable, PM0 */
149 #define SYS_CTRL_DCGCGPT_GPT1 0x00000002 /**< GPT1 clock enable, PM0 */
150 #define SYS_CTRL_DCGCGPT_GPT0 0x00000001 /**< GPT0 clock enable, PM0 */
151 /** @} */
152 /*---------------------------------------------------------------------------*/
153 /** \name SYS_CTRL_SRGPT register bits
154  * @{
155  */
156 #define SYS_CTRL_SRGPT_GPT3 0x00000008 /**< GPT3 is reset */
157 #define SYS_CTRL_SRGPT_GPT2 0x00000004 /**< GPT2 is reset */
158 #define SYS_CTRL_SRGPT_GPT1 0x00000002 /**< GPT1 is reset */
159 #define SYS_CTRL_SRGPT_GPT0 0x00000001 /**< GPT0 is reset */
160 /** @} */
161 /*---------------------------------------------------------------------------*/
162 /** \name SYS_CTRL_PWRDBG register bits
163  * @{
164  */
165 #define SYS_CTRL_PWRDBG_FORCE_WARM_RESET 0x00000008
166 /** @} */
167 /*---------------------------------------------------------------------------*/
168 /** \name Possible values for the SYS_CTRL_CLOCK_CTRL_SYS_DIV bits
169  * @{
170  */
171 #define SYS_CTRL_CLOCK_CTRL_SYS_DIV_32MHZ 0x00000000
172 #define SYS_CTRL_CLOCK_CTRL_SYS_DIV_16MHZ 0x00000001
173 #define SYS_CTRL_CLOCK_CTRL_SYS_DIV_8MHZ 0x00000002
174 #define SYS_CTRL_CLOCK_CTRL_SYS_DIV_4MHZ 0x00000003
175 #define SYS_CTRL_CLOCK_CTRL_SYS_DIV_2MHZ 0x00000004
176 #define SYS_CTRL_CLOCK_CTRL_SYS_DIV_1MHZ 0x00000005
177 #define SYS_CTRL_CLOCK_CTRL_SYS_DIV_500KHZ 0x00000006
178 #define SYS_CTRL_CLOCK_CTRL_SYS_DIV_250KHZ 0x00000007
179 /** @} */
180 /*---------------------------------------------------------------------------*/
181 /** \name Possible values for the SYS_CTRL_CLOCK_CTRL_IO_DIV bits
182  * @{
183  */
184 #define SYS_CTRL_CLOCK_CTRL_IO_DIV_32MHZ 0x00000000
185 #define SYS_CTRL_CLOCK_CTRL_IO_DIV_16MHZ 0x00000100
186 #define SYS_CTRL_CLOCK_CTRL_IO_DIV_8MHZ 0x00000200
187 #define SYS_CTRL_CLOCK_CTRL_IO_DIV_4MHZ 0x00000300
188 #define SYS_CTRL_CLOCK_CTRL_IO_DIV_2MHZ 0x00000400
189 #define SYS_CTRL_CLOCK_CTRL_IO_DIV_1MHZ 0x00000500
190 #define SYS_CTRL_CLOCK_CTRL_IO_DIV_500KHZ 0x00000600
191 #define SYS_CTRL_CLOCK_CTRL_IO_DIV_250KHZ 0x00000700
192 /** @} */
193 /*---------------------------------------------------------------------------*/
194 /** \name SYS_CTRL_RCGCUART Register Bit-Masks
195  * @{
196  */
197 #define SYS_CTRL_RCGCUART_UART1 0x00000002 /**< UART1 Clock, CPU running */
198 #define SYS_CTRL_RCGCUART_UART0 0x00000001 /**< UART0 Clock, CPU running */
199 /** @} */
200 /*---------------------------------------------------------------------------*/
201 /** \name SYS_CTRL_SCGCUART Register Bit-Masks
202  * @{
203  */
204 #define SYS_CTRL_SCGCUART_UART1 0x00000002 /**< UART1 Clock, CPU IDLE */
205 #define SYS_CTRL_SCGCUART_UART0 0x00000001 /**< UART0 Clock, CPU IDLE */
206 /** @} */
207 /*---------------------------------------------------------------------------*/
208 /** \name SYS_CTRL_RCGCUART Register Bit-Masks
209  * @{
210  */
211 #define SYS_CTRL_DCGCUART_UART1 0x00000002 /**< UART1 Clock, PM0 */
212 #define SYS_CTRL_DCGCUART_UART0 0x00000001 /**< UART0 Clock, PM0 */
213 /** @} */
214 /*---------------------------------------------------------------------------*/
215 /** \name SYS_CTRL_SRUART register bits
216  * @{
217  */
218 #define SYS_CTRL_SRUART_UART1 0x00000002 /**< UART1 module is reset */
219 #define SYS_CTRL_SRUART_UART0 0x00000001 /**< UART0 module is reset */
220 /** @} */
221 /*---------------------------------------------------------------------------*/
222 /** \name SYS_CTRL_PMCTL register values
223  * @{
224  */
225 #define SYS_CTRL_PMCTL_PM3 0x00000003 /**< PM3 */
226 #define SYS_CTRL_PMCTL_PM2 0x00000002 /**< PM2 */
227 #define SYS_CTRL_PMCTL_PM1 0x00000001 /**< PM1 */
228 #define SYS_CTRL_PMCTL_PM0 0x00000000 /**< PM0 */
229 /** @} */
230 /*---------------------------------------------------------------------------*/
231 /** \name SysCtrl 32-kHz oscillator selection
232  *
233  * Prefer the crystal oscillator for time accuracy, and the RC oscillator for
234  * cost and power consumption
235  * @{
236  */
237 /* Defaults to RC oscillator unless the configuration tells us otherwise */
238 #ifdef SYS_CTRL_CONF_OSC32K_USE_XTAL
239 #define SYS_CTRL_OSC32K_USE_XTAL SYS_CTRL_CONF_OSC32K_USE_XTAL
240 #else
241 #define SYS_CTRL_OSC32K_USE_XTAL 0
242 #endif
243 /** @} */
244 /*---------------------------------------------------------------------------*/
245 /** \name SysCtrl functions
246  * @{
247  */
248 /** \brief Initialises the System Control Driver. The main purpose of this
249  * function is to power up and select clocks and oscillators
250  * \note This function depends on ioc_init() having been called beforehand. */
251 void sys_ctrl_init();
252 
253 /** \brief Generates a warm reset through the SYS_CTRL_PWRDBG register */
254 void sys_ctrl_reset();
255 
256 /** @} */
257 
258 #endif /* SYS_CTRL_H_ */
259 
260 /**
261  * @}
262  * @}
263  */
void sys_ctrl_reset()
Generates a warm reset through the SYS_CTRL_PWRDBG register.
Definition: sys-ctrl.c:93
void sys_ctrl_init()
Initialises the System Control Driver.
Definition: sys-ctrl.c:54