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

📄 usrappinit.c

📁 ARM板驱动程序源代码
💻 C
字号:
/* usrAppInit.c - stub application initialization routine *//* Copyright 1984-1998 Wind River Systems, Inc. *//*modification history--------------------01a,02jun98,ms   written*//*DESCRIPTIONInitialize user application code.*/ #include "prjcomps.h"#include "ioslib.h"#include "iolib.h"#include "vxWorks.h"#include "config.h"#include "string.h"#include "intLib.h"#include "logLib.h"#include "stdio.h"#include "time.h"#include "taskLib.h"#include "wdLib.h" #include "vxLib.h"#include "tyLib.h"#include "blkIo.h"#include "drv/timer/timerDev.h"#include "tickLib.h"#include "ramDrv.h"#include "dosFsLib.h"#include "ipProto.h"#include "ifLib.h"#include "usrLib.h"#include "routeLib.h"#include "end.h"#ifdef INCLUDE_SOUND_CODEC#include "drv/audio/dac3550drv.h"void demo(){	printf("\t\t/************************************************************************************************/\n");	printf("\t\tThis is the demo of Vxworks BSP on Atmel AT91RM9200DK/EK Board\n");	printf("\t\t1)UART\n");	printf("\t\t\t\tIf you see this demo, the UART0 is OK\n");	printf("\t\t\t\tTo test UART1, please connect UART1 to a terminal and run uartOpen(\"/tyCo/1\")\n\n");	printf("\t\t\t\trun uartClose() to close it\n\n");		printf("\t\t2)Ethernet\n");	printf("\t\t\t\tTo test ethernet, please run telnet on your host machine.\n\n");			printf("\t\t3)USB host\n");	printf("\t\t\t\tPlease insert a USB disk into USB host socket. And run \'ll \"/bd\" \' on target shell.\n\n");		printf("\t\t4)USB Slave\n");	printf("\t\t\t\tPlease connect usb slave port to your PC, and run at91usb.exe on your PC.\n\n");		printf("\t\t5)DAC3550 sound(Only EK)\n");	printf("\t\t\t\tRun \'PlaySound($repeat_count) to play internal sound data\' , for example, PlaySound(20)\n\n");	printf("\t\t\t\tOR\n");	printf("\t\t\t\tRun \'WavPlay($wavfile)\' to play a wav file, for example, WavPlay(\"/bd/tada.wav\")\n\n");		printf("\t\t6)VGA Display\n");	printf("\t\t\t\tPlease Run \'displayBmp($filepath) to display a BMP file.\'\n\n");	printf("\t\t\t\tOR\n");	printf("\t\t\t\tPlease Run \'displayString($string) to display a String.\'\n\n");			printf("\t\t7)DataFlash Card(Because MMC can not work on DK/EK, use DataFlash instead)\n");	printf("\t\t\t\tPlease run \'ll \"/card0\" \' on target shell, if it is OK. the filesystem on CF card is ready\n");	printf("\t\t\t\tIf not, Please run \'ll \"/card0\" \' on target shell, if it is OK. the filesystem on CF card is ready\n\n");	printf("\t\t\t\tOR\n");	printf("\t\t\t\tPlease Run \'displayString($string) to display a String.\'\n\n");					printf("\t\t8)Compact Flash Card(Only DK)\n");	printf("\t\t\t\tPlease run \'ll \"/card0\" \' on target shell, if it is OK. the filesystem on CF card is ready\n");	printf("\t\t\t\tIf not, Please run \'ll \"/card0\" \' on target shell, if it is OK. the filesystem on CF card is ready\n\n");	printf("\t\t\t\tOR\n");	printf("\t\t\t\tPlease Run \'displayString($string) to display a String.\'\n\n");		//printf("This is the demo of Vxworks BSP on Atmel AT91RM9200DK/EK Board\n");}#endifvoid uartTest(char* name){	int uartFd=0;	int c;	char msg1[]="Hello, This message is from UART1 of EV board\n\r";	char msg2[]="Please give a sentence\n\r";	char msg3[] ="\r\nI get your message, and will close myself\n\r";	if(uartFd!=0) close(uartFd);	uartFd = open (name, O_RDWR, 0);	(void) ioctl (uartFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);	(void) ioctl (uartFd, FIOSETOPTIONS, OPT_TERMINAL);	write(uartFd,msg1,strlen(msg1));	write(uartFd,msg2,strlen(msg2));		while(read(uartFd,&c,1)==1)	{		//write(uartFd,&c,1);		if(c=='\n') break;	}	write(uartFd,msg3,strlen(msg3));		close(uartFd);uartFd=0;	}#ifdef __EK__#ifdef INCLUDE_SOUND_CODECvoid WavPlay(const char* filePath){	DEV_HDR* pDev;	int count = 20;	pDev = iosDevFind("/sound",0);	if(pDev==0) 	{		pDev = dac3550DevCreate ("/sound", 0,0);//		pDev = iosDevFind("/sound",0);	}	if(pDev)	{		int fdSnd = iosOpen(pDev,"/dsp",0,0);		int fd = iosFdNew(pDev,"/dsp",fdSnd);		WAVFILE* wfile = 	WavOpenForRead(filePath);		int blksize=0x8000;		int count , total = 0;		char * ubuf=0;		if(wfile)		{			iosIoctl (fd, SNDCTL_DSP_GETBLKSIZE,(int)&blksize);			/*iosIoctl (fd, SNDCTL_DSP_SPEED,(int)&(wfile->wavinfo.SamplingRate));*/			total = wfile->wavinfo.DataBytes ;			ubuf = malloc(blksize);			while(total)			{				count = read(wfile->fd,ubuf,(total>blksize)?blksize:total);				total-=count;				iosWrite (fd, (char*)ubuf, count);			}			free(ubuf); ubuf = 0;			wavfile_free(wfile);			wfile= 0;		}				iosClose(fd);		iosFdFree(fd);	}else logMsg("Can not find sound device\n",0,0,0,0,0,0);}void PlaySound(int count){	DEV_HDR* pDev;	#include "src/drv/audio/sound.c"	if(count==0) count = 2;		pDev = dac3550DevCreate ("/sound", 0,0);	//pDev = iosDevFind("/sound",0);	if(pDev)	{		int fdSnd = iosOpen(pDev,"/dsp",0,0);		int fd = iosFdNew(pDev,"/dsp",fdSnd);				for(;count>0;count--)			iosWrite (fd, (char*)wav_file, AT91C_WAV_FILE_SIZE);				iosClose(fd);		iosFdFree(fd);	}		}#endif#endif/******************************************************************************** usrAppInit - initialize the users application*/ void usrAppInit (void)    {#ifdef	USER_APPL_INIT	USER_APPL_INIT;		/* for backwards compatibility */#endif#ifdef INCLUDE_SOUND_CODEC{	//PlaySound(20);	}	#endif	 /* ifAddrSet("eth0", "172.20.9.111");    ifMaskSet("eth0", 0xffff0000);*/ /*     if (ipAttach(1, ETH_DEV_NAME) == OK)    {        ifAddrSet(ETH_DEV_NAME"1", "12.25.2.12");        ifMaskSet(ETH_DEV_NAME"1", 0xffffff00);    }*/  //  routeAdd("0.0.0.0", "172.20.1.254");    /* add application specific code here */    }

⌨️ 快捷键说明

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