2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * o Redistributions of source code must retain the above copyright notice, this list
9 * of conditions and the following disclaimer.
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.
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.
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.
30 #if !defined(__FSL_OSC_HAL_H__)
31 #define __FSL_OSC_HAL_H__
36 #include "fsl_device_registers.h"
37 #include "fsl_osc_features.h"
39 /*! @addtogroup osc_hal*/
42 /*! @file fsl_osc_hal.h */
44 /*******************************************************************************
46 ******************************************************************************/
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;
56 /*******************************************************************************
58 ******************************************************************************/
60 #if defined(__cplusplus)
62 #endif /* __cplusplus*/
64 /*! @name oscillator control APIs*/
69 * @brief Enables the external reference clock for the oscillator.
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.
76 * @param baseAddr Oscillator register base address
77 * @param enable enable/disable the clock
79 void OSC_HAL_SetExternalRefClkCmd(uint32_t baseAddr, bool enable);
82 * @brief Gets the external reference clock enable setting for the oscillator.
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.
89 * @param baseAddr Oscillator register base address
90 * @return enable clock enable/disable setting
92 bool OSC_HAL_GetExternalRefClkCmd(uint32_t baseAddr);
95 * @brief Enables/disables the external reference clock in stop mode.
97 * This function enables/disables the external reference clock (OSCERCLK) when an
98 * MCU enters the stop mode.
100 * @param baseAddr Oscillator register base address
101 * @param enable enable/disable setting
103 void OSC_HAL_SetExternalRefClkInStopModeCmd(uint32_t baseAddr, bool enable);
106 * @brief Gets the external reference clock enable setting in stop mode.
108 * This function gets the external reference clock (OSCERCLK) enable setting when an
109 * MCU enters stop mode.
111 * @param baseAddr Oscillator register base address
113 bool OSC_HAL_GetExternalRefClkInStopModeCmd(uint32_t baseAddr);
116 * @brief Enables the capacitor configuration for the oscillator.
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.
122 * @param baseAddr Oscillator register base address
123 * @param capacitorConfig Capacitor configuration. (2p, 4p, 8p, 16p)
124 * @param enable enable/disable the Capacitor configuration
126 void OSC_HAL_SetCapacitorCmd(uint32_t baseAddr,
127 osc_capacitor_config_t capacitorConfig,
131 * @brief Gets the capacitor configuration for a specific oscillator.
133 * This function gets the specified capacitors configuration for an
136 * @param baseAddr Oscillator register base address
137 * @param capacitorConfig Capacitor configuration.
138 * @return enable enable/disable setting
140 bool OSC_HAL_GetCapacitorCmd(uint32_t baseAddr,
141 osc_capacitor_config_t capacitorConfig);
143 #if FSL_FEATURE_OSC_HAS_EXT_REF_CLOCK_DIVIDER
145 * @brief Sets the external reference clock divider.
147 * This function sets the divider for the external reference clock.
149 * @param baseAddr Oscillator register base address
150 * @param divider divider settings
152 void OSC_HAL_SetExternalRefClkDivCmd(uint32_t baseAddr, uint32_t divider);
155 * @brief Gets the external reference clock divider.
157 * This function gets the divider for the external reference clock.
159 * @param baseAddr Oscillator register base address
160 * @return divider divider settings
162 uint32_t OSC_HAL_GetExternalRefClkDivCmd(uint32_t baseAddr);
167 #if defined(__cplusplus)
169 #endif /* __cplusplus*/
173 #endif /* __FSL_OSC_HAL_H__*/
174 /*******************************************************************************
176 ******************************************************************************/