BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
bc2.h
Go to the documentation of this file.
1 /* Copyright 2012-2014, Peter A. Bigot
2  *
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 are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the software nor the names of its contributors may be
16  * used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
75 #ifndef BSP430_PERIPH_BC2_H
76 #define BSP430_PERIPH_BC2_H
77 
78 #include <bsp430/clock.h>
79 #include <bsp430/periph.h>
80 
87 #define BSP430_MODULE_BC2 defined(__MSP430_HAS_BC2__)
88 
89 #if defined(BSP430_DOXYGEN) || (BSP430_MODULE_BC2 - 0)
90 
108 #ifndef configBSP430_BC2_TRIM_TO_MCLK
109 #define configBSP430_BC2_TRIM_TO_MCLK 0
110 #endif /* configBSP430_BC2_TRIM_TO_MCLK */
111 
112 #if (configBSP430_BC2_TRIM_TO_MCLK - 0) && ! (configBSP430_TIMER_CCACLK - 0)
113 #warning configBSP430_BC2_TRIM_TO_MCLK requested without configBSP430_TIMER_CCACLK
114 #endif /* configBSP430_BC2_TRIM_TO_MCLK */
115 
125 #if defined(BSP430_DOXYGEN)
126 #define BSP430_BC2_TRIM_TO_MCLK include <bsp430/platform.h>
127 #endif /* BSP430_DOXYGEN */
128 
129 #if defined(BSP430_DOXYGEN) || (configBSP430_BC2_TRIM_TO_MCLK - 0)
130 
153 int iBSP430bc2TrimToMCLK_ni (unsigned long mclk_Hz);
154 #endif /* configBSP430_BC2_TRIM_TO_MCLK */
155 
157 /* Simplify conditionally-defined macros to avoid reference to
158  * non-existent values. The chip supports an external crystal for
159  * LFXT1 iff LFXT1S_0 is defined */
160 #if defined(XT2OF)
161 #define BSP430_BC2_XT2OF_ XT2OF
162 #else /* XT2OF */
163 #define BSP430_BC2_XT2OF_ 0
164 #endif /* XT2OF */
165 #if defined(LFXT1OF)
166 #define BSP430_BC2_LFXT1OF_ LFXT1OF
167 #else /* LFXT1OF */
168 #define BSP430_BC2_LFXT1OF_ 0
169 #endif /* LFXT1OF */
170 
184 #define BSP430_BC2_LFXT1_IS_FAULTED_NI() (BCSCTL3 & BSP430_BC2_LFXT1OF_)
185 
199 #define BSP430_BC2_XT2_IS_FAULTED_NI() (BC2CTL3 & BSP430_BC2_XT2OF_)
200 
219 #if defined(BSP430_DOXYGEN) || ! defined(BSP430_CLOCK_LFXT1_IS_FAULTED_NI)
220 #define BSP430_CLOCK_LFXT1_IS_FAULTED_NI() ((BCSCTL3 & (LFXT1S0 | LFXT1S1)) || BSP430_BC2_LFXT1_IS_FAULTED_NI())
221 #endif /* BSP430_CLOCK_LFXT1_IS_FAULTED_NI */
222 
238 #if defined(BSP430_DOXYGEN) || ! defined(BSP430_CLOCK_XT2_IS_FAULTED_NI)
239 #define BSP430_CLOCK_XT2_IS_FAULTED_NI() ((BCSCTL1 & XT2OFF) || BSP430_BC2_XT2_IS_FAULTED_NI())
240 #endif /* BSP430_CLOCK_XT2_IS_FAULTED_NI */
241 
248 #if defined(BSP430_DOXYGEN) || ! defined(BSP430_CLOCK_CLEAR_FAULTS_NI)
249 #define BSP430_CLOCK_CLEAR_FAULTS_NI() do { \
250  BSP430_CLOCK_OSC_CLEAR_FAULT_NI(); \
251  } while (0)
252 #endif /* BSP430_CLOCK_CLEAR_FAULTS_NI */
253 
254 #ifndef BSP430_CLOCK_LFXT1_XCAP
255 
256 #define BSP430_CLOCK_LFXT1_XCAP XCAP_1
257 #endif /* BSP430_CLOCK_LFXT1_XCAP */
258 
260 #define BSP430_CLOCK_NOMINAL_VLOCLK_HZ 12000U
261 
263 #define BSP430_CLOCK_PUC_MCLK_HZ 1100000UL
264 
265 #endif /* BSP430_MODULE_BC2 */
266 
267 #endif /* BSP430_PERIPH_BC2_H */
int iBSP430bc2TrimToMCLK_ni(unsigned long mclk_Hz)
Clock-related functions implemented on all MSP430 MCUs.
Generic peripheral support for MSP430 MCUs.