
/******************** (C) COPYRIGHT 2022 SONiX *******************************
* COMPANY:	SONiX
* DATE:		2022/01/03
* AUTHOR:		Roger
* IC:			SN8F5754
*____________________________________________________________________________
* REVISION		Date				User		Description
* 1.0					2022/01/03	Roger		1. First release
*____________________________________________________________________________
*****************************************************************************/



/*_____ I N C L U D E S _________________________________*/
#define __XRAM_SFR_H__
#include <SN8F5754.h>
#include "buzzer.h"
/*_____ F U N C T I O N S _______________________________*/
void BZ_Initialize2khz(void);
void BZ_Initialize4khz(void);
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    IO_PORT3_OUTPUT_LOW        P3M |= 0xFF;    P3 &= 0x00;

/**
 *	@Brief		main: Buzzer Test Demo Function
 *	@param		None
 *	@return		None
 */

void main(void)
{
	/*
   *	System initial:
	 *	(1) GPIO
	 *  Pwm App Fuction Selcect:
	 *	(2) 2Khz Buzzer Init or 4Khz Buzzer Init
	 */		
		GPIO_Initialization();												/*	(1)	*/
		BZ_Initialize2khz();													/*	(2)	*/
//		BZ_Initialize4khz();												/*	(2)	*/
		while(1)
		{		
			WDTR = 0x5A;																/*	Clear Watchdog Timer	*/
		}
}

/**
 *	@Brief		initial GPIO status
 *	@param		None
 *	@return		None
 */

void GPIO_Initialization(void)
{			
		IO_PORT0_OUTPUT_LOW
		IO_PORT1_OUTPUT_LOW
		IO_PORT2_OUTPUT_LOW
		IO_PORT3_OUTPUT_LOW
}

/**
 *	@Brief		BZ_ExecuteBz2khzInit:	2kHz Buzzer Initial Function
 *	@param		None
 *	@return		None
 */

void BZ_Initialize2khz(void)
{
		
		BZM	=	mskBZM_BZRATE_DIV16384;								/*	Init 2Khz Buzzer Freq Division	*/
	
		BZM	|=	mskBZM_BZEN;												/*	Buzzer Enable	*/
}

/**
 *	@Brief		BZ_ExecuteBz4khzInit:	4kHz Buzzer Initial Function
 *	@param		None
 *	@return		None
 */
void BZ_Initialize4khz(void)
{
		
		BZM	 =	mskBZM_BZRATE_DIV8192;							/*	Init 4Khz Buzzer Freq Division	*/
	
		BZM	|=	mskBZM_BZEN;												/*	Buzzer Enable	*/
}