| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

C:/pdl_v10/library/driver/reset/reset.c
Go to the documentation of this file.

    00001 /*******************************************************************************
    00002 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
    00003 *
    00004 * This software is owned and published by:
    00005 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA  94088-3453 ("Spansion").
    00006 *
    00007 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
    00008 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
    00009 *
    00010 * This software contains source code for use with Spansion
    00011 * components. This software is licensed by Spansion to be adapted only
    00012 * for use in systems utilizing Spansion components. Spansion shall not be
    00013 * responsible for misuse or illegal use of this software for devices not
    00014 * supported herein.  Spansion is providing this software "AS IS" and will
    00015 * not be responsible for issues arising from incorrect user implementation
    00016 * of the software.
    00017 *
    00018 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
    00019 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
    00020 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
    00021 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
    00022 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
    00023 * WARRANTY OF NONINFRINGEMENT.
    00024 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
    00025 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
    00026 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
    00027 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
    00028 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
    00029 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
    00030 * SAVINGS OR PROFITS,
    00031 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    00032 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
    00033 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
    00034 * FROM, THE SOFTWARE.
    00035 *
    00036 * This software may be replicated in part or whole for the licensed use,
    00037 * with the restriction that this Disclaimer and Copyright notice must be
    00038 * included with each copy of this software, whether used in part or whole,
    00039 * at all times.
    00040 */
    00041 /******************************************************************************/
    00052 /******************************************************************************/
    00053 /* Include files                                                              */
    00054 /******************************************************************************/
    00055 #include "reset.h"
    00056 #include <string.h>
    00057
    00058 #if (defined(PDL_PERIPHERAL_RESET_ACTIVE))
    00059
    00065
    00066 /******************************************************************************/
    00067 /* Local pre-processor symbols/macros ('#define')                             */
    00068 /******************************************************************************/
    00069
    00070 /******************************************************************************/
    00071 /* Global variable definitions (declared in header file with 'extern')        */
    00072 /******************************************************************************/
    00073 stc_reset_result_t stcStoredResetCause;
    00074
    00075
    00076 /******************************************************************************/
    00077 /* Local type definitions ('typedef')                                         */
    00078 /******************************************************************************/
    00079
    00080 /******************************************************************************/
    00081 /* Local function prototypes ('static')                                       */
    00082 /******************************************************************************/
    00083
    00084 /******************************************************************************/
    00085 /* Local variable definitions ('static')                                      */
    00086 /******************************************************************************/
    00087
    00088 /******************************************************************************/
    00089 /* Function implementation - global ('extern') and local ('static')           */
    00090 /******************************************************************************/
    00091
    00108 en_result_t Reset_GetCause(stc_reset_result_t* pstcResult)
    00109 {
    00110   stc_crg_rst_str_field_t stcReadResetCause;
    00111
    00112   stcReadResetCause = FM0P_CRG->RST_STR_f;
    00113
    00114   // Check Power-on bit
    00115   if (1 == stcReadResetCause.PONR)
    00116   {
    00117     pstcResult->bPowerOn = TRUE;
    00118   }
    00119   else
    00120   {
    00121     pstcResult->bPowerOn = FALSE;
    00122   }
    00123
    00124   // Check INITX/External Reset bit
    00125   if (1 == stcReadResetCause.INITX)
    00126   {
    00127     pstcResult->bInitx = TRUE;
    00128   }
    00129   else
    00130   {
    00131     pstcResult->bInitx = FALSE;
    00132   }
    00133
    00134   // Check Software Watchdog bit
    00135   if (1 == stcReadResetCause.SWDT)
    00136   {
    00137     pstcResult->bSoftwareWatchdog = TRUE;
    00138   }
    00139   else
    00140   {
    00141     pstcResult->bSoftwareWatchdog = FALSE;
    00142   }
    00143
    00144   // Check Hardware Watchdog bit
    00145   if (1 == stcReadResetCause.HWDT)
    00146   {
    00147     pstcResult->bHardwareWatchdog = TRUE;
    00148   }
    00149   else
    00150   {
    00151     pstcResult->bHardwareWatchdog = FALSE;
    00152   }
    00153
    00154   // Check Clock Supervisor bit
    00155   if (1 == stcReadResetCause.CSVR)
    00156   {
    00157     pstcResult->bClockSupervisor = TRUE;
    00158   }
    00159   else
    00160   {
    00161     pstcResult->bClockSupervisor = FALSE;
    00162   }
    00163
    00164   // Check Anomalous Frequency bit
    00165   if (1 == stcReadResetCause.FCSR)
    00166   {
    00167     pstcResult->bAnomalousFrequency = TRUE;
    00168   }
    00169   else
    00170   {
    00171     pstcResult->bAnomalousFrequency = FALSE;
    00172   }
    00173
    00174   // Check Software Reset bit
    00175   if (1 == stcReadResetCause.SRST)
    00176   {
    00177     pstcResult->bSoftware = TRUE;
    00178   }
    00179   else
    00180   {
    00181     pstcResult->bSoftware = FALSE;
    00182   }
    00183
    00184   // Copy reset cause structure argument contents to global reset cause structure
    00185   memcpy(&stcStoredResetCause, pstcResult, sizeof(stcStoredResetCause));
    00186
    00187   return Ok;
    00188 } // Reset_GetCause
    00189
    00201 en_result_t Reset_GetStoredCause( stc_reset_result_t* pstcResult )
    00202 {
    00203   // Copy global reset cause structure contents to reset cause structure argument
    00204   memcpy(pstcResult, &stcStoredResetCause, sizeof(stcStoredResetCause));
    00205
    00206   return Ok;
    00207 }
    00208
    00210
    00211 #endif // #if (defined(PDL_PERIPHERAL_RESET_ACTIVE))
    00212
    00213 /******************************************************************************/
    00214 /* EOF (not truncated)                                                        */
    00215 /******************************************************************************/