]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/osc/fsl_osc_hal.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / hal / TARGET_Freescale / TARGET_KPSDK_MCUS / TARGET_KPSDK_CODE / hal / osc / fsl_osc_hal.h
1 /*
2  * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  *   of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  *   list of conditions and the following disclaimer in the documentation and/or
13  *   other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  *   contributors may be used to endorse or promote products derived from this
17  *   software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #if !defined(__FSL_OSC_HAL_H__)
31 #define __FSL_OSC_HAL_H__
32
33 #include <stdint.h>
34 #include <stdbool.h>
35 #include <assert.h>
36 #include "fsl_device_registers.h"
37 #include "fsl_osc_features.h"
38
39 /*! @addtogroup osc_hal*/
40 /*! @{*/
41
42 /*! @file fsl_osc_hal.h */
43
44 /*******************************************************************************
45  * Definitions
46  ******************************************************************************/
47
48 /*! @brief Oscillator capacitor load configurations.*/
49 typedef enum _osc_capacitor_config {
50     kOscCapacitor2p = OSC_CR_SC2P_MASK,     /*!< 2 pF capacitor load */
51     kOscCapacitor4p = OSC_CR_SC4P_MASK,     /*!< 4 pF capacitor load */
52     kOscCapacitor8p = OSC_CR_SC8P_MASK,     /*!< 8 pF capacitor load */
53     kOscCapacitor16p = OSC_CR_SC16P_MASK    /*!< 16 pF capacitor load */
54 } osc_capacitor_config_t;
55
56 /*******************************************************************************
57  * API
58  ******************************************************************************/
59
60 #if defined(__cplusplus)
61 extern "C" {
62 #endif /* __cplusplus*/
63
64 /*! @name oscillator control APIs*/
65 /*@{*/
66
67
68 /*!
69  * @brief Enables the external reference clock for the oscillator.
70  *
71  * This function  enables the external reference clock output 
72  * for the oscillator, OSCERCLK. This clock is used
73  * by many peripherals. It should be enabled at an early system initialization
74  * stage to ensure the peripherals can select and use it.
75  *
76  * @param baseAddr Oscillator register base address
77  * @param enable   enable/disable the clock
78  */
79 void OSC_HAL_SetExternalRefClkCmd(uint32_t baseAddr, bool enable);
80
81 /*!
82  * @brief Gets the external reference clock enable setting for the oscillator.
83  *
84  * This function gets the external reference clock output enable setting
85  * for the oscillator , OSCERCLK. This clock  is used
86  * by many peripherals. It should be enabled at an early system initialization
87  * stage to ensure the peripherals could select and use it.
88  * 
89  * @param baseAddr Oscillator register base address
90  * @return enable  clock enable/disable setting
91  */
92 bool OSC_HAL_GetExternalRefClkCmd(uint32_t baseAddr);
93
94 /*!
95  * @brief Enables/disables the external reference clock in stop mode.
96  *
97  * This function  enables/disables the external reference clock (OSCERCLK) when an
98  * MCU enters the stop mode. 
99  *
100  * @param baseAddr Oscillator register base address
101  * @param enable   enable/disable setting
102  */
103 void OSC_HAL_SetExternalRefClkInStopModeCmd(uint32_t baseAddr, bool enable);
104
105 /*!
106  * @brief Gets the external reference clock enable setting in stop mode.
107  *
108  * This function gets the external reference clock (OSCERCLK) enable setting when an
109  * MCU enters stop mode. 
110  *
111  * @param baseAddr Oscillator register base address
112  */
113 bool OSC_HAL_GetExternalRefClkInStopModeCmd(uint32_t baseAddr);
114
115 /*!
116  * @brief Enables the capacitor configuration for the oscillator.
117  *
118  * This function  enables the specified capacitors configuration for the 
119  * oscillator. This should be done in the early system level initialization function call
120  * based on the system configuration.
121  *
122  * @param baseAddr Oscillator register base address
123  * @param capacitorConfig Capacitor configuration. (2p, 4p, 8p, 16p)
124  * @param enable          enable/disable the Capacitor configuration 
125  */
126 void OSC_HAL_SetCapacitorCmd(uint32_t baseAddr, 
127                              osc_capacitor_config_t capacitorConfig,
128                              bool enable);
129
130 /*!
131  * @brief Gets the capacitor configuration for a specific oscillator.
132  *
133  * This function gets the specified capacitors configuration for an 
134  * oscillator.
135  *
136  * @param baseAddr Oscillator register base address
137  * @param capacitorConfig Capacitor configuration. 
138  * @return enable         enable/disable setting
139  */
140 bool OSC_HAL_GetCapacitorCmd(uint32_t baseAddr, 
141                              osc_capacitor_config_t capacitorConfig);
142
143 #if FSL_FEATURE_OSC_HAS_EXT_REF_CLOCK_DIVIDER
144 /*!
145  * @brief Sets the external reference clock divider.
146  *
147  * This function sets the divider for the external reference clock.
148  *
149  * @param baseAddr Oscillator register base address
150  * @param divider   divider settings
151  */
152 void OSC_HAL_SetExternalRefClkDivCmd(uint32_t baseAddr, uint32_t divider);
153
154 /*!
155  * @brief Gets the external reference clock divider.
156  *
157  * This function gets the divider for the external reference clock.
158  *
159  * @param baseAddr Oscillator register base address
160  * @return divider   divider settings
161  */
162 uint32_t OSC_HAL_GetExternalRefClkDivCmd(uint32_t baseAddr);
163 #endif
164
165 /*@}*/
166
167 #if defined(__cplusplus)
168 }
169 #endif /* __cplusplus*/
170
171 /*! @}*/
172
173 #endif /* __FSL_OSC_HAL_H__*/
174 /*******************************************************************************
175  * EOF
176  ******************************************************************************/
177