iswu.c

来自「Microchip的官方PIC24H系列16位单片机的外设源程序库。」· C语言 代码 · 共 36 行

C
36
字号
#include <p30fxxxx.h>
#include <reset.h>

/********************************************************************
* Function Name     : isWU
* Description       : Checks whether wake up from SLEEP 
*                     is due to MCLR or Interrupt or POR or BOR.
* Parameters        : None
* Return Value      : Returns 2 for MCLR, 1 for interrupt, 
*                     3 for POR,4 for BOR.
*********************************************************************/

char isWU(void)
{
   if( RCONbits.SLEEP)
   {
       if(RCONbits.EXTR)
       {
           return 2;        /* wakeup is due to MCLR */
       }
      
       if(RCONbits.POR)
       {
		   return 3;        /* wakeup is due to POR */
       } 
	
       if(RCONbits.BOR)
       {   
           return 4;         /* wakeup is due to BOR */
       }
       else
           return 1;             /* else, wakeup is due to interrupt. */
   }
  return 0;       
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?