/******************** (C) COPYRIGHT 2021 SONiX *******************************
* COMPANY:	SONiX
* DATE:		2021/12/24
* IC:			SN8F5762
*____________________________________________________________________________
* REVISION		Date				AUTHOR		Description
* 1.0					2021/12/24	SONiX			1. First release
*____________________________________________________________________________
*****************************************************************************/
/*_____ I N C L U D E S _________________________________*/
#include <SN8F5762.h>

/*_____ F U N C T I O N S _______________________________*/
void GPIO_Initialization(void);

/*_____ D E F I N I T I O N S ___________________________*/

/*_____ D E C L A R A T I O N S _________________________*/

/*_____ M A C R O S _____________________________________*/
#define	IO_PORT0_OUTPUT_LOW		P0M |= 0xFF;	P0 &= 0x00;
#define	IO_PORT1_OUTPUT_LOW		P1M |= 0xFF;	P1 &= 0x00;
#define	IO_PORT2_OUTPUT_LOW		P2M |= 0xFF;	P2 &= 0x00;

#define WAKEUP_IO_INPUT				P0M &= ~0x10;	

/**
 *	@Brief		main: STOP Mode Test Demo Function
 *	@param		None
 *	@retval		None
 */

void main(void)
{
	/*	Initialize GPIO status	*/
	GPIO_Initialization();					
	
	WAKEUP_IO_INPUT				/*	set one of port0 IO	to input for GPIO wakeup function	*/
	
	/*	Step 1: System into STOP mode, measure system current about uA order
							, the STOP() macro define on SN8F5762.h		
			Step 2: If system into STOP mode, IO status keep output high 
							Change port0 IO level then system will be wakeup to normal mode, IO status return to output low	*/			
	//P00=1;	   // TEST IO
	STOP()          		
	//P00=0;     // TEST IO
	
	while(1);
}

/**
 *	@Brief		Initialize GPIO status
 *	@param		None
 *	@retval		None
 */
void GPIO_Initialization(void)
{
	/*	Set whole IOs to output low	*/
	IO_PORT0_OUTPUT_LOW
	IO_PORT1_OUTPUT_LOW
	IO_PORT2_OUTPUT_LOW
}

