void AppInit_TCPIP (void) { #if EMAC_CFG_MAC_ADDR_SEL == EMAC_MAC_ADDR_SEL_CFG NetIF_MAC_Addr[0] = 0x00; NetIF_MAC_Addr[1] = 0x50; NetIF_MAC_Addr[2] = 0xC2; NetIF_MAC_Addr[3] = 0x25; NetIF_MAC_Addr[4] = 0x60; NetIF_MAC_Addr[5] = 0x01; #endif #if uC_TTCP_MODULE > 0 BSP_USART_Init(TTCP_COMM_SEL, 38400); #endif err = Net_Init(); ip = NetASCII_Str_to_IP((CPU_CHAR *) ownIPAddress, &err); msk = NetASCII_Str_to_IP((CPU_CHAR *)"255.255.255.0", &err); gateway = NetASCII_Str_to_IP((CPU_CHAR *)"192.168.1.1", &err); err = NetIP_CfgAddrThisHost(ip, msk); err = NetIP_CfgAddrDfltGateway(gateway); #if uC_TTCP_MODULE > 0 TTCP_Init(); #endif info_printf("tcp/ip network initialized ...\n"); }
/* * @brief */ void Netchan_Init(void) { Net_Init(); net_showpackets = Cvar_Get("net_showpackets", "0", 0, NULL); net_showdrop = Cvar_Get("net_showdrop", "0", 0, NULL); }
void Net_Para_Modi_Chk(void) { if(Net_Para_Modi_Flag EQ NET_PARA_MODI_FLAG) { if(memcmp((INT8U *)&localm[NETIF_ETH].IpAdr, (INT8U *)&Screen_Para.Net_Para.IP, 4) != 0 ||\ memcmp((INT8U *)&localm[NETIF_ETH].DefGW, (INT8U *)&Screen_Para.Net_Para.Gate, 4) != 0 ||\ memcmp((INT8U *)&localm[NETIF_ETH].NetMask, (INT8U *)&Screen_Para.Net_Para.Mask, 4) != 0 ||\ memcmp(own_hw_adr, ETH_Mac_Para.Mac, 6) != 0) { Net_Init(); } Net_Para_Modi_Flag = 0; } }
/* 矩阵键盘按下之后执行的函数 */ void keyfunc(int key) { switch(key) { case 1:{/*step-*/impulse_step--;if(impulse_step<=1){impulse_step=1;}}break; case 2:{/*step+*/impulse_step++;if(impulse_step>=50){impulse_step=50;}}break; case 3:{/*num_impulse-*/impulse_num-=impulse_step;if(impulse_num<=1){impulse_num=1;}}break; case 4:{/*num_impulse+*/impulse_num+=impulse_step;if(impulse_num>=500){impulse_num=500;}}break; case 5:{/**/}break; case 6:{/**/}break; case 7:{/**/}break; case 8:{/*启动脉冲模式*/if(outputstate==0){is_impulse=1;LCD_Print(35,0,"脉冲");TIM_CtrlPWMOutputs(TIM1, ENABLE);TIM_ITConfig(TIM1,TIM_IT_Update,ENABLE);}}break; case 9:{/*初始化WIFI*/Net_Init();}break; case 10:{/*开始定时接收数据*/TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE );}break; case 11:{/*关闭输出*/TIM_CtrlPWMOutputs(TIM1, DISABLE);TIM_ITConfig(TIM1,TIM_IT_Update,DISABLE );outputstate=0;LCD_Print(35,0,"停止");}break; case 12:{/*启动输出*/TIM_CtrlPWMOutputs(TIM1, ENABLE);TIM_ITConfig(TIM1,TIM_IT_Update,ENABLE );outputstate=1;LCD_Print(35,0,"启动");}break; case 13:{/*f-*/sinFre-=0.5;if(sinFre<=10){sinFre=0.5;}}break; case 14:{/*f+*/sinFre+=0.5;if(sinFre<=60){sinFre=60;}}break; case 15:{/*U-*/U-=5;if(U<=10){U=10;}}break; case 16:{/*U+*/U+=5;if(U<=250){U=250;}}break; } }
void main() { Proc_PID pid; int i; /* * Initialize variables specific to a given kernel. * IMPORTANT: Only variable assignments and nothing else can be * done in this routine. */ Main_InitVars(); /* * Initialize machine dependent info. MUST BE CALLED HERE!!!. */ Mach_Init(); Sync_Init(); /* * Initialize the debugger. */ Dbg_Init(); /* * Initialize the system module, particularly the fact that there is an * implicit DISABLE_INTR on every processor. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Sys_Init().\n"); } Sys_Init(); /* * Now allow memory to be allocated by the "Vm_BootAlloc" call. Memory * can be allocated by this method until "Vm_Init" is called. After this * then the normal memory allocator must be used. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Vm_BootInit().\n"); } Vm_BootInit(); /* * Initialize all devices. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Dev_Init().\n"); } Dev_Init(); /* * Initialize the mappings of keys to call dump routines. * Must be after Dev_Init. */ if (main_DoDumpInit) { if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Dump_Init().\n"); } Dump_Init(); } /* * Initialize the timer, signal, process, scheduling and synchronization * modules' data structures. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Proc_Init().\n"); } Proc_Init(); if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Sync_LockStatInit().\n"); } Sync_LockStatInit(); if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Timer_Init().\n"); } Timer_Init(); if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Sig_Init().\n"); } Sig_Init(); if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Sched_Init().\n"); } Sched_Init(); /* * Sys_Printfs are not allowed before this point. */ main_PanicOK++; printf("Sprite kernel: %s\n", SpriteVersion()); /* * Set up bins for the memory allocator. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Fs_Bin\n"); } Fs_Bin(); if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Net_Bin\n"); } Net_Bin(); /* * Initialize virtual memory. After this point must use the normal * memory allocator to allocate memory. If you use Vm_BootAlloc then * will get a panic into the debugger. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Vm_Init\n"); } Vm_Init(); /* * malloc can be called from this point on. */ /* * Initialize the main process. Must be called before any new * processes are created. * Dependencies: Proc_InitTable, Sched_Init, Vm_Init, Mem_Init */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Proc_InitMainProc\n"); } Proc_InitMainProc(); /* * Initialize the network and the routes. It would be nice if we * could call Net_Init earlier so that we can use the debugger earlier * but we must call Vm_Init first. VM could be changed so that we * could move the call earlier however. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Net_Init\n"); } Net_Init(); if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Net_RouteInit\n"); } Net_RouteInit(); /* * Enable server process manager. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Proc_ServerInit\n"); } Proc_ServerInit(); /* * Initialize the recovery module. Do before Rpc and after Vm_Init. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Recov_Init\n"); } Recov_Init(); /* * Initialize the data structures for the Rpc system. This uses * Vm_RawAlloc to so it must be called after Vm_Init. * Dependencies: Timer_Init, Vm_Init, Net_Init, Recov_Init */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Rpc_Init\n"); } Rpc_Init(); /* * Configure devices that may or may not exist. This needs to be * done after Proc_InitMainProc because the initialization routines * use SetJump which uses the proc table entry for the main process. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Dev_Config\n"); } Dev_Config(); /* * Initialize profiling after the timer and vm stuff is set up. * Dependencies: Timer_Init, Vm_Init */ if (main_DoProf) { Prof_Init(); } /* * Allow interrupts from now on. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Enabling interrupts\n"); } ENABLE_INTR(); if (main_Debug) { DBG_CALL; } /* * Sleep for a few seconds to calibrate the idle time ticks. */ Sched_TimeTicks(); /* * Start profiling, if desired. */ if (main_DoProf) { (void) Prof_Start(); } /* * Do an initial RPC to get a boot timestamp. This allows * servers to detect when we crash and reboot. This will set the * system clock too, although rdate is usually done from user level later. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Call Rpc_Start\n"); } Rpc_Start(); /* * Initialize the file system. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Call Fs_Init\n"); } Fs_Init(); /* * Before starting up any more processes get a current directory * for the main process. Subsequent new procs will inherit it. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Call Fs_ProcInit\n"); } Fs_ProcInit(); if (main_PrintInitRoutines) { Mach_MonPrintf("Bunch of call funcs\n"); } /* * Start the clock daemon and the routine that opens up the swap directory. */ Proc_CallFunc(Vm_Clock, (ClientData) NIL, 0); Proc_CallFunc(Vm_OpenSwapDirectory, (ClientData) NIL, 0); /* * Start the process that synchronizes the filesystem caches * with the data kept on disk. */ Proc_CallFunc(Fsutil_SyncProc, (ClientData) NIL, 0); /* * Create a few RPC server processes and the Rpc_Daemon process which * will create more server processes if needed. */ if (main_NumRpcServers > 0) { for (i=0 ; i<main_NumRpcServers ; i++) { (void) Rpc_CreateServer((int *) &pid); } } (void) Proc_NewProc((Address) Rpc_Daemon, PROC_KERNEL, FALSE, &pid, "Rpc_Daemon", FALSE); if (main_PrintInitRoutines) { Mach_MonPrintf("Creating Proc server procs\n"); } /* * Create processes to execute functions. */ (void) Proc_ServerProcCreate(FSCACHE_MAX_CLEANER_PROCS + VM_MAX_PAGE_OUT_PROCS); /* * Create a recovery process to monitor other hosts. Can't use * Proc_CallFunc's to do this because they can be used up waiting * for page faults against down servers. (Alternatively the VM * code could be fixed up to retry page faults later instead of * letting the Proc_ServerProc wait for recovery.) */ (void) Proc_NewProc((Address) Recov_Proc, PROC_KERNEL, FALSE, &pid, "Recov_Proc", FALSE); /* * Set up process migration recovery management. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Proc_MigInit\n"); } Proc_MigInit(); /* * Call the routine to start test kernel processes. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Calling Main_HookRoutine\n"); } Main_HookRoutine(); /* * Print out the amount of memory used. */ printf("MEMORY %d bytes allocated for kernel\n", vmMemEnd - mach_KernStart); /* * Start up the first user process. */ if (main_PrintInitRoutines) { Mach_MonPrintf("Creating Init\n"); } (void) Proc_NewProc((Address) Init, PROC_KERNEL, FALSE, &pid, "Init", FALSE); (void) Sync_WaitTime(time_OneYear); printf("Main exiting\n"); Proc_Exit(0); }
static int BURNT_action(int argc, char *argv[]) { UINT i; UINT32 src_addr=0x100000; UINT32 dest_addr=FLASH_BASE; UINT32 src,dest; UINT32 fileSize=0; UINT32 blockSize=0; INT flash_type; if( !_net_init ) { if( Net_Init(_dhcp) < 0 ) { uprintf("ERROR: Network initialization failed!\n"); return -1; } _net_init=1; } uprintf("Waiting for download ...\n"); if( TFTP_Download((UCHAR *)src_addr,(ULONG *)&fileSize,_dhcp)==0 ) { uprintf("\nFlash programming "); if( _net_init )DisableIRQ(); flash_type=FindFlash(); if( _net_init )EnableIRQ(); if( flash_type < 0 ) { uprintf("ERROR: Un-supported flash type !!\n"); return -1; } // Write program if( (fileSize&0x3) )fileSize=((fileSize&(~0x3))+4);//word-aligment i=fileSize; src=src_addr; dest=dest_addr; while(i) { blockSize=flash[flash_type].BlockSize(dest); if( _net_init )DisableIRQ(); flash[flash_type].BlockErase(dest, blockSize); if( i < blockSize ) { flash[flash_type].BlockWrite(dest, (UCHAR *)src, i); blockSize=i; } else { flash[flash_type].BlockWrite(dest, (UCHAR *)src, blockSize); } if( _net_init )EnableIRQ(); src+=blockSize; dest+=blockSize; i-=blockSize; uprintf("."); } uprintf(" OK!\n"); } else { uprintf("\nDownload error!\n"); return -1; } // verify data uprintf("Write data verifing "); for(i=0;i<fileSize;i+=4) { if( (i&0xFFFF)== 0x0 )uprintf("."); if( *((volatile unsigned int *)(src_addr+i))!=*((volatile unsigned int *)(dest_addr+i)) ) { uprintf("ERROR: Data failed @ 0x%08x \n", dest_addr+i); return -1; } } uprintf(" OK!\n"); return 0; }