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

📄 user.c

📁 isp1161驱动代码是我下载并该动后而成,还有点缺点,但对你可能有点帮助
💻 C
字号:
/*
**  Kenobi2          version 1.3
**
**      ** This code has been made to check/learn the 1161 functionalities ** 
**      ** Release 25-Feb-2002                                             **
**
**      OKANO, Akifumi 
**      
**		Computing Segment, Semisonductors Div, Philips Japan Ltd.
**      akifumi.okano@philips.com
**      +81-3-3740-4668 
*/


/*
**		"ISP1161 hardware check/test harness"
**
**			14,15-May-2001
**
**			OKANO, Akifumi
**
**			Computing Segment,
**			Philips Seminconductors - Tokyo
**
**		This code has been made for the functional 
**		check/study of ISP1161/ISP1161 eveluation board
*/


#include		<stdio.h>
#include	    "dos.h"
#include		"conio.h"
#include		<time.h>

#include		"hc_comm.h"
#include		"hw_acces.h"
#include		"init.h"
#include		"ui.h"
#include		"isr_as.h"
#include		"sing.h"
#include		"printer.h"
#include		"general.h"


void		static_test( void );
void 		options_handler( int argc, char **argv );
void 		parse_music_list( char *str );


extern unsigned		_stklen		= 0x4000u;		//	Modify stack size


void test( void );

user( int argc, char **argv )
{
	unsigned long 	done	= 0;
	int				key;

//	outportb( 0x37A, inportb( 0x37A ) | 0x10 );
	
	options_handler( argc, argv );
	
	start_message();
	
	initialize();

//	static_test();

	while ( !done )
	{
		asynchronus_iso_buffer_fill();
	
		if ( key_polling_timing() )
		{
			done	= user_debug_command_handler( user_debug_command_key() );
			status_monitor();				
			isr_flag_routine_dspatch();
		}
	}

	quit();

	return ( 0 );
}


void static_test( void )
{
	/*
	**	Hc/Dc access test
	*/
	
	outport( 0x292, 0xA8 );
	outport( 0x290, 0xAAAA );

	outport( 0x296, 0xB2 );
	outport( 0x294, 0x5555 );

	/*
	**	Normal access
	*/
	
	outport( 0x292, 0x28 );
	mprintf( LIGHTGRAY, CONTINUE, "normal access  Hc   : 0x%04X\n", inport( 0x290 ) );
	
	outport( 0x296, 0xB3 );
	mprintf( LIGHTGRAY, CONTINUE, "normal access  Dc   : 0x%04X\n", inport( 0x294 ) );

	/*
	**	Mixed access
	*/

	outport( 0x292, 0x28 );
	outport( 0x296, 0xB3 );
	
	mprintf( LIGHTGRAY, CONTINUE, "mixed access   Hc   : 0x%04X\n", inport( 0x290 ) );
	mprintf( LIGHTGRAY, CONTINUE, "mixed access   Dc   : 0x%04X\n", inport( 0x294 ) );

	mprintf( LIGHTGRAY, CONTINUE, "----------------------------\n", inport( 0x294 ) );


	outport( 0x292, 0xA8 );
	outport( 0x296, 0xB2 );
	
	outport( 0x290, 0xBBBB );
	outport( 0x294, 0x6666 );

	outport( 0x292, 0x28 );
	mprintf( LIGHTGRAY, CONTINUE, "normal access  Hc   : 0x%04X\n", inport( 0x290 ) );
	
	outport( 0x296, 0xB3 );
	mprintf( LIGHTGRAY, CONTINUE, "normal access  Dc   : 0x%04X\n", inport( 0x294 ) );


}


void options_handler( int argc, char **argv )
{
	int		i;
	
	g_host_IRQ_num			= 0xFF;
	g_ISA_base_address		= 0xFFFF;
	
	for ( i = 0; i < MAX_NUM_OF_AUDIO_FILES; i++ )
		*g_sing_file_str[ i ]	= 0;
	
	for ( i = 1; i < argc; i++ )
	{
		if ( *argv[ i ] == '-' )
		{
			switch ( *(argv[ i ] + 1) )
			{
			

			/**
			 **		environment settings
			 **/
			
				case 'h' :		//	IRQ number for HC
					g_host_IRQ_num	= atoi( argv[ ++i ] );
					break;
				case 'd' :		//	IRQ number for DC
					mprintf( RED, CONTINUE, "  Option \"-d\" has not been supported yet.\n" );
					break;
				case 'b' :		//	ISA base address
					sscanf( argv[ ++i ], "%X", &g_ISA_base_address );
					break;
				case 't' :		//	for ITL test
					sscanf( argv[ ++i ], "%d", &g_ITL_test_value );
					break;

			/**
			 **		Audio settings
			 **/
		
				case 'a' :		//	music file selection
					strcpy( g_sing_file_str[ 0 ], argv[ ++i ] );
					break;
				case 'l' :		//	music LIST file selection
					strcpy( g_sing_list_file_str, argv[ ++i ] );
					parse_music_list( g_sing_list_file_str );
					break;
					
					
			/**
			 **		Printer settings
			 **/
		
				case 'p' :		//	Audio file selection
					strcpy( g_printer_default_file_path, argv[ ++i ] );
					break;
					
					
			/**
			 **		Help settings
			 **/
		
				case '?' :
					break;
				default  :
					mprintf( RED, CONTINUE, "  Un-supported option \"-d\".\n" );
					break;
			}
		}
	}

	if ( *g_sing_file_str == 0 )
		strcpy( g_sing_file_str, AUDIO_FILENAME );
	
	if ( g_host_IRQ_num == 0xFF )
		g_host_IRQ_num	= DEFAULT_HC_IRQ_NUM;
	
	if ( g_ISA_base_address == 0xFFFF )
		g_ISA_base_address		= ISA_BASE_ADDR;
	
	g_1161_command_address		= g_ISA_base_address + 2;
	g_1161_data_address			= g_ISA_base_address;
}


void parse_music_list( char *str )
{
	FILE 	*fp;
	char 	file_name[ 256 ];
	int		len;
	int		i;
	
	if ( NULL == (fp	= fopen( str, "r" )) )
	{
		mprintf( RED, CONTINUE, "error @ file open for \"-l\" option switch" );
		return;
	}
	
	for ( i = 0; i < MAX_NUM_OF_AUDIO_FILES; )
	{
		if ( NULL ==  fgets( file_name, FILE_NAME_LENGTH, fp ))
			break;
			
		*( file_name + (len	= strlen( file_name )  - 1) )	= 0;
		
		if ( !len )
			continue;
		
		if ( (*file_name == '!') || (*file_name == '#') )
			continue;
		
		strcpy( g_sing_file_str[ i++ ], file_name );
	}
	
	fclose ( fp );
}














⌨️ 快捷键说明

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