#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include "PwrMgnt.h"

#ifdef _PWRMGNT

/******************************************************************************
 * Function:        RESET_SOURCE PwrMgnt_ResetSource(void)
 *
 * PreCondition:    None   
 *
 * Input:           None
 *
 * Output:          RESET_SOURCE : Enum value representing the source of reset
 *
 * Side Effects:    None
 *
 * Overview:        This function returns the source of reset.
 *
 * Note:            None
 *****************************************************************************/
RESET_SOURCE PwrMgnt_ResetSource(void)
{
   if(RCONbits.POR)
   {
      return(POWER_ON_Reset);
   }
   if((RCONbits.BOR) && !(RCONbits.POR))
   {
      return(BURN_OUT_Reset);
   }
   if(RCONbits.WDTO)
   {
      return(WATCHDOG_Reset);
   }
   if(RCONbits.SWR)
   {
      return(SOFTWARE_Reset);
   }
   if(RCONbits.EXTR)
   {
      return(EXTERNAL_Reset);
   }
   if(RCONbits.CM)
   {
      return(CFG_WORD_MISMATCH_Reset);
   }
   if(RCONbits.IOPUWR)
   {
      return(ILLEGAL_INSTR_Reset);
   }
   if(RCONbits.TRAPR)
   {
      return(TRAP_Reset);
   }
}

#else
#warning "Does not build on this target"
#endif
