PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
reset.c
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3 *
4 * This software is owned and published by:
5 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6 *
7 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9 *
10 * This software contains source code for use with Spansion
11 * components. This software is licensed by Spansion to be adapted only
12 * for use in systems utilizing Spansion components. Spansion shall not be
13 * responsible for misuse or illegal use of this software for devices not
14 * supported herein. Spansion is providing this software "AS IS" and will
15 * not be responsible for issues arising from incorrect user implementation
16 * of the software.
17 *
18 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23 * WARRANTY OF NONINFRINGEMENT.
24 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30 * SAVINGS OR PROFITS,
31 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34 * FROM, THE SOFTWARE.
35 *
36 * This software may be replicated in part or whole for the licensed use,
37 * with the restriction that this Disclaimer and Copyright notice must be
38 * included with each copy of this software, whether used in part or whole,
39 * at all times.
40 */
41 /******************************************************************************/
52 /******************************************************************************/
53 /* Include files */
54 /******************************************************************************/
55 #include "reset.h"
56 #include <string.h>
57 
58 #if (defined(PDL_PERIPHERAL_RESET_ACTIVE))
59 
65 
66 /******************************************************************************/
67 /* Local pre-processor symbols/macros ('#define') */
68 /******************************************************************************/
69 
70 /******************************************************************************/
71 /* Global variable definitions (declared in header file with 'extern') */
72 /******************************************************************************/
74 
75 
76 /******************************************************************************/
77 /* Local type definitions ('typedef') */
78 /******************************************************************************/
79 
80 /******************************************************************************/
81 /* Local function prototypes ('static') */
82 /******************************************************************************/
83 
84 /******************************************************************************/
85 /* Local variable definitions ('static') */
86 /******************************************************************************/
87 
88 /******************************************************************************/
89 /* Function implementation - global ('extern') and local ('static') */
90 /******************************************************************************/
91 
109 {
110  stc_crg_rst_str_field_t stcReadResetCause;
111 
112  stcReadResetCause = FM4_CRG->RST_STR_f;
113 
114  // Check Power-on bit
115  if (1 == stcReadResetCause.PONR)
116  {
117  pstcResult->bPowerOn = TRUE;
118  }
119  else
120  {
121  pstcResult->bPowerOn = FALSE;
122  }
123 
124  // Check INITX/External Reset bit
125  if (1 == stcReadResetCause.INITX)
126  {
127  pstcResult->bInitx = TRUE;
128  }
129  else
130  {
131  pstcResult->bInitx = FALSE;
132  }
133 
134  // Check Low Voltage Detection bit
135  if (1 == stcReadResetCause.LVDH)
136  {
137  pstcResult->bLowVoltageDetection = TRUE;
138  }
139  else
140  {
141  pstcResult->bLowVoltageDetection = FALSE;
142  }
143 
144  // Check Software Watchdog bit
145  if (1 == stcReadResetCause.SWDT)
146  {
147  pstcResult->bSoftwareWatchdog = TRUE;
148  }
149  else
150  {
151  pstcResult->bSoftwareWatchdog = FALSE;
152  }
153 
154  // Check Hardware Watchdog bit
155  if (1 == stcReadResetCause.HWDT)
156  {
157  pstcResult->bHardwareWatchdog = TRUE;
158  }
159  else
160  {
161  pstcResult->bHardwareWatchdog = FALSE;
162  }
163 
164  // Check Clock Supervisor bit
165  if (1 == stcReadResetCause.CSVR)
166  {
167  pstcResult->bClockSupervisor = TRUE;
168  }
169  else
170  {
171  pstcResult->bClockSupervisor = FALSE;
172  }
173 
174  // Check Anomalous Frequency bit
175  if (1 == stcReadResetCause.FCSR)
176  {
177  pstcResult->bAnomalousFrequency = TRUE;
178  }
179  else
180  {
181  pstcResult->bAnomalousFrequency = FALSE;
182  }
183 
184  // Check Software Reset bit
185  if (1 == stcReadResetCause.SRST)
186  {
187  pstcResult->bSoftware = TRUE;
188  }
189  else
190  {
191  pstcResult->bSoftware = FALSE;
192  }
193 
194  // Copy reset cause structure argument contents to global reset cause structure
195  memcpy(&stcStoredResetCause, pstcResult, sizeof(stcStoredResetCause));
196 
197  return Ok;
198 } // Reset_GetCause
199 
214 {
215  // Copy global reset cause structure contents to reset cause structure argument
216  memcpy(pstcResult, &stcStoredResetCause, sizeof(stcStoredResetCause));
217 
218  return Ok;
219 }
220 
222 
223 #endif // #if (defined(PDL_PERIPHERAL_RESET_ACTIVE))
224 
225 /******************************************************************************/
226 /* EOF (not truncated) */
227 /******************************************************************************/