⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 machdep.c

📁 YAMAHA的铃音芯片的测试程序
💻 C
字号:
#include "pccdef.h"
#include "OMAP_MPU_Addr.h"
#include "predef.h"
#include "Machdep.h"

/*************************************************************/
/* Function Name : machdep_Wait                              */
/* Description   : make enough security time for MPU read    */
/*                 and write                                 */    
/* ***********************************************************/
void machdep_Wait( UINT32 wait_time )
{
  UINT32 i = 0, count;
	
  if(wait_time < 2000)
  {
	i++;
  }
  else
  {
	count = (UINT32)(wait_time / 2000);
	for( ; i < count; i++);
  }		
}

/*************************************************************/
/* Function Group Name : System_I/F                          */
/* Description         : As the interface of MPU and MA-3    */
/* Member function     : machdep_ReadStatusFlagReg           */
/*                       machdep_WriteStatusFlagReg          */
/*                       machdep_WriteDataReg                */
/*                       machdep_ReadDataReg                 */
/*************************************************************/

UINT8 machdep_ReadStatusFlagReg( void )
{
	UINT8	data;

	/* use the LCD Control Register as the StatusFlag Register */

	data = LCD_Control;

	machdep_Wait( 70 );

	return data;
}

void machdep_WriteStatusFlagReg( UINT8	data )
{
	/* use the LCD Control Register as the StatusFlag Register */
 
	LCD_Control = data;
	// YMU762C_MA-3L2
	machdep_Wait( 600 );
}

void machdep_WriteDataReg( UINT8 data )
{
	/* use the LCD Date Register as the Data Register */

	LCD_Data = data;

	// YMU762C_MA-3L2
	machdep_Wait( 600 );

}

UINT8 machdep_ReadDataReg( void )
{
	UINT8	data;

	/* use the LCD Date Register as the Data Register */

	data = LCD_Data;

	machdep_Wait( 70 );

	return data;
}

/********************************************************/
/* Function Name : machdep_WaitImmediateFifoEmpty       */
/* Description   : Check the FIFO of the Immediate      */
/*                 write path whether it's empty.       */
/* Note          : the FIFO size is 64KB                */
/********************************************************/

SINT32 machdep_WaitImmediateFifoEmpty( void )
{
	UINT8 read_data;

	do 
	{
		read_data = machdep_ReadStatusFlagReg();
		
	} while( (read_data&MA_EMP_W)==0 );

	return MASMW_SUCCESS;
}


/****************************************************************/
/* Function Name : machdep_WaitValidData                        */
/* Describe      : wait valid data via immediate read path      */ 
/* Note          : used for MaDevDrv_ReceiveData                */
/****************************************************************/

SINT32 machdep_WaitValidData( UINT8 flag )
{
	UINT8	read_data;

	do
	{
		read_data = machdep_ReadStatusFlagReg();
    
    /* time out (>1.5ms) */		 
	}
	while ( ( read_data & flag ) == 0 );

	return MASMW_SUCCESS;
}

/******************************************************************/
/* Function Name : machdep_CheckFifoInterrupt                     */
/* Description   : Check the FIFO interrupt bit whether it is set */ 
/* Note          : used for MaDevDrv_SendDelayedPacket            */
/******************************************************************/

SINT32 machdep_CheckFifoInterrupt( void )
{
  UINT8 read_data;
  
  do
  {
    machdep_WriteStatusFlagReg( (UINT8)MA_INTERRUPT_FLAG_REG );  /* Check FIFO interrupt bit */
    read_data = machdep_ReadDataReg(); 
  }
  while( ( read_data & 0x80 ) == 0 );
	
  machdep_WriteStatusFlagReg( (UINT8)MA_INTERRUPT_FLAG_REG );    /* Clear FIFO interrupt bit */
  machdep_WriteDataReg( 0x80 ); 
	
  return MASMW_SUCCESS;
}

⌨️ 快捷键说明

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