📄 usrappinit.c
字号:
/* usrAppInit.c - stub application initialization routine */
/* Copyright 1984-1998 Wind River Systems, Inc. */
/*
modification history
--------------------
01a,02jun98,ms written
*/
/*
DESCRIPTION
Initialize user application code.
*/
/******************************************************************************
*
* usrAppInit - initialize the users application
*/
#include "vxWorks.h"
#include "stdio.h"
#include "ioLib.h"
#include "time.h"
#include "vxWorks.h"
#include "iv.h"
#include "ioLib.h"
#include "iosLib.h"
#include "intLib.h"
#include "errnoLib.h"
#include "sioLib.h"
#include "sysLib.h"
#include "stdlib.h"
#include "string.h"
#include "LCD_Private.h" /* private modul definitions & config */
#include "GUI_Protected.h"
extern void LedSetByte(unsigned int Status);
extern void test(void);
extern void mytcp(void);
extern void myudp(void);
extern void f485(void);
extern void s485(void);
static unsigned int sta=0x01;
extern int done_flag,power_mode,showidle;
extern unsigned char PARAMETER_BUF0[];
extern unsigned short *pParameterBuf;
int idgui;
void myled(void)
{
static int count=0;
while(1)
{
pParameterBuf=PARAMETER_BUF0;
count++;
if(count>(*(pParameterBuf+35)*2/5))
{
count=0;
if(done_flag==1)
{
done_flag=0;
}
else
{
power_mode=1;
showidle=1;
/* if(*(pParameterBuf+36)==0)
{
LCD_Power_Off();
}
*/
}
}
if(sta==1)
{
LedSetByte(0xfe);
sta=0;
}
else
{
LedSetByte(0xff);
sta=1;
}
taskDelay(100) ;
}
}
void usrAppInit (void)
{
int id1,id3,id4,id5,id6;
int fd,len;
char buf[5];
if (ipAttach(0, "dm") != OK)
{
printf ("Failed to attach to END device dm0\n");
return;
}
if (usrNetIfConfig ("dm", 0, "192.168.9.100", "wld0",0xffffff00) != OK)
{
printf ("Failed to config END device dm0\n");
return;
}
if (ipAttach(1, "dm") != OK)
{
printf ("Failed to attach to END device dm1\n");
return;
}
if (usrNetIfConfig ("dm", 1, "192.168.10.100", "wld1",0xffffff00) != OK)
{
printf ("Failed to config END device dm1\n");
return;
}
nand_config("/nand/");
LedSetByte(0xff);
if(ERROR == (id1=taskSpawn("myled",101,0,100,(FUNCPTR)myled,0,0,0,0,0,0,0,0,0,0)))
{
printf("\r\nERROR in task myled Spawn!");
return;
}
if(ERROR == (idgui=taskSpawn("test",102,0,3000,(FUNCPTR)test,0,0,0,0,0,0,0,0,0,0)))
{
printf("\r\nERROR in task test Spawn!");
return;
}
if(ERROR == (id3=taskSpawn("mytcp",103,0,1000,(FUNCPTR)mytcp,0,0,0,0,0,0,0,0,0,0)))
{
printf("\r\nERROR in task mytcp Spawn!");
return;
}
if(ERROR == (id4=taskSpawn("myudp",103,0,1000,(FUNCPTR)myudp,0,0,0,0,0,0,0,0,0,0)))
{
printf("\r\nERROR in task myudp Spawn!");
return;
}
if(ERROR == (id5=taskSpawn("f485",103,0,1000,(FUNCPTR)f485,0,0,0,0,0,0,0,0,0,0)))
{
printf("\r\nERROR in task mytcp Spawn!");
return;
}
if(ERROR == (id6=taskSpawn("s485",103,0,1000,(FUNCPTR)s485,0,0,0,0,0,0,0,0,0,0)))
{
printf("\r\nERROR in task myudp Spawn!");
return;
}
}
void wldxtb1(void)
{
int fd,len;
unsigned char buf[15];
fd=open("/nand/test",O_RDWR|O_CREAT,0);
if(fd<=0)
printf("can not open");
buf[0]=2;
buf[1]=3;
buf[2]=4;
buf[3]=5;
buf[4]=6;
len=write(fd,buf,5);
if(len!=5)
printf("can not write\n");
close(fd);
}
void wldxtb2(void)
{
int fd,len;
unsigned char buf[15];
fd=open("/nand/test",O_RDWR|O_CREAT,0);
if(fd<=0)
printf("can not open");
buf[0]=0;
buf[1]=0;
buf[2]=0;
buf[3]=0;
buf[4]=0;
len=read(fd,buf,5);
if(len!=5)
{
printf("can not read\n");
return;
}
printf("%d\n",buf[0]);
printf("%d\n",buf[1]);
printf("%d\n",buf[2]);
printf("%d\n",buf[3]);
printf("%d\n",buf[4]);
close(fd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -