]> 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/rcm/fsl_rcm_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 / rcm / fsl_rcm_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_RCM_HAL_H__)
31 #define __FSL_RCM_HAL_H__
32
33 #include <stdint.h>
34 #include <stdbool.h>
35 #include <assert.h>
36 #include "fsl_device_registers.h"
37 #include "fsl_rcm_features.h"
38
39 /*! @addtogroup rcm_hal*/
40 /*! @{*/
41
42 /*! @file fsl_rcm_hal.h */
43
44 /*******************************************************************************
45  * Definitions
46  ******************************************************************************/
47
48 /*! @brief System Reset Source Name definitions */
49 typedef enum _rcm_source_names {
50     kRcmWakeup,                     /* low-leakage wakeup reset */
51     kRcmLowVoltDetect,              /* low voltage detect reset */
52     kRcmLossOfClk,                  /* loss of clock reset */
53     kRcmLossOfLock,                 /* loss of lock reset */
54     kRcmWatchDog,                   /* watch dog reset */
55     kRcmExternalPin,                /* external pin reset */
56     kRcmPowerOn,                    /* power on reset */
57     kRcmJtag,                       /* JTAG generated reset */
58     kRcmCoreLockup,                 /* core lockup reset */
59     kRcmSoftware,                   /* software reset */
60     kRcmSystem,                     /* system reset request bit set reset */
61     kRcmEzport,                     /* EzPort reset */
62     kRcmStopModeAckErr,             /* stop mode ack error reset */
63     kRcmSrcNameMax
64 } rcm_source_names_t;
65
66 /*! @brief Reset pin filter select in Run and Wait modes */
67 typedef enum _rcm_filter_run_wait_modes {
68     kRcmFilterDisabled,          /* all filtering disabled */
69     kRcmFilterBusClk,            /* Bus clock filter enabled */
70     kRcmFilterLpoClk,            /* LPO clock filter enabled */
71     kRcmFilterReserverd          /* reserved setting */
72 } rcm_filter_run_wait_modes_t;
73
74 /*******************************************************************************
75  * API
76  ******************************************************************************/
77
78 /*!
79  * @brief Gets the reset source status.
80  *
81  * This function gets the current reset source status for a specified source.
82  *
83  * @param baseAddr     Register base address of RCM
84  * @param srcName      reset source name
85  * @return status      true or false for specified reset source
86  */
87 bool RCM_HAL_GetSrcStatusCmd(uint32_t baseAddr, rcm_source_names_t srcName);
88
89 /*!
90  * @brief Sets the reset pin filter in stop mode.
91  *
92  * This function  sets the reset pin filter enable setting in stop mode.
93  *
94  * @param baseAddr     Register base address of RCM
95  * @param enable      enable or disable the filter in stop mode
96  */
97 static inline void RCM_HAL_SetFilterStopModeCmd(uint32_t baseAddr, bool enable)
98 {
99     BW_RCM_RPFC_RSTFLTSS(baseAddr, enable);
100 }
101
102 /*!
103  * @brief Gets the reset pin filter in stop mode.
104  *
105  * This function gets the reset pin filter enable setting in stop mode.
106  *
107  * @param baseAddr     Register base address of RCM
108  * @return enable      true/false to enable or disable the filter in stop mode
109  */
110 static inline bool RCM_HAL_GetFilterStopModeCmd(uint32_t baseAddr)
111 {
112     return (bool)BR_RCM_RPFC_RSTFLTSS(baseAddr);
113 }
114
115 /*!
116  * @brief Sets the reset pin filter in run and wait mode.
117  *
118  * This function sets the reset pin filter enable setting in run/wait mode.
119  *
120  * @param baseAddr     Register base address of RCM
121  * @param mode  to be set for reset filter in run/wait mode
122  */
123 static inline void RCM_HAL_SetFilterRunWaitMode(uint32_t baseAddr, rcm_filter_run_wait_modes_t mode)
124 {
125     BW_RCM_RPFC_RSTFLTSRW(baseAddr, mode);
126 }
127
128 /*!
129  * @brief Gets the reset pin filter for stop mode.
130  *
131  * This function gets the reset pin filter enable setting for stop mode.
132  *
133  * @param baseAddr     Register base address of RCM
134  * @return mode  for reset filter in run/wait mode
135  */
136 static inline rcm_filter_run_wait_modes_t RCM_HAL_GetFilterRunWaitMode(uint32_t baseAddr)
137 {
138     return (rcm_filter_run_wait_modes_t)BR_RCM_RPFC_RSTFLTSRW(baseAddr);
139 }
140
141 /*!
142  * @brief Sets the reset pin filter width.
143  *
144  * This function sets the reset pin filter width.
145  *
146  * @param baseAddr     Register base address of RCM
147  * @param width  to be set for reset filter width
148  */
149 static inline void RCM_HAL_SetFilterWidth(uint32_t baseAddr, uint32_t width)
150 {
151     BW_RCM_RPFW_RSTFLTSEL(baseAddr, width);
152 }
153
154 /*!
155  * @brief Gets the reset pin filter for stop mode.
156  *
157  * This function gets the reset pin filter width.
158  *
159  * @param baseAddr     Register base address of RCM
160  * @return width reset filter width
161  */
162 static inline uint32_t RCM_HAL_GetFilterWidth(uint32_t baseAddr)
163 {
164     return (uint32_t)BR_RCM_RPFW_RSTFLTSEL(baseAddr);
165 }
166
167 /*!
168  * @brief Gets the EZP_MS_B pin assert status.
169  *
170  * This function gets the easy port mode status (EZP_MS_B) pin assert status.
171  *
172  * @param baseAddr     Register base address of RCM
173  * @return status  true - asserted, false - reasserted
174  */
175 static inline bool RCM_HAL_GetEasyPortModeStatusCmd(uint32_t baseAddr)
176 {
177     return (bool)BR_RCM_MR_EZP_MS(baseAddr);
178 }
179
180 #if defined(__cplusplus)
181 extern "C" {
182 #endif /* __cplusplus*/
183
184 /*! @name Reset Control Module APIs*/
185 /*@{*/
186
187 /*@}*/
188
189 #if defined(__cplusplus)
190 }
191 #endif /* __cplusplus*/
192
193 /*! @}*/
194
195 #endif /* __FSL_RCM_HAL_H__*/
196 /*******************************************************************************
197  * EOF
198  ******************************************************************************/
199