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

📄 main_b2.c

📁 实现基于ip2022的MPEG2 TS的IP组播接收
💻 C
字号:
#include <ipOS.h>#include <ipHAL.h>#include <ipStack.h>#include <ipEthernet.h>/* * IP2022 configuration block */CONFIG_BLOCK (        FUSE0(FUSE0_XTAL | FUSE0_PIN_DIV1 | FUSE0_POUT_DIV2 | FUSE0_WUDP_128us | FUSE0_WUDX_1ms),        FUSE1(0),        OSC1_FREQ,        "UBICOM",        "starter",        CONFIG_VER(0, 0, 0, 0),        CONFIG_DATE(0, 0, 0),        CONFIG_DATE(0, 0, 0)        );#define RUNTIME_DEBUG 0/* * Define the filename to be used for assertions. */THIS_FILE("main");u8_t mac_addr[6] = {0x00, 0x03, 0x64, 0x00, 0x01, 0x21};struct udp_socket *us;struct netbuf *nb1,*nb2,*nb;struct ip_datalink_instance *eii;volatile netpage_t npst __attribute__ ((section(".gpr.npst"))); //bit 0:np1 ready, bit 1:np2 ready								//bit 2:np1 act, bit 3:np2 actvolatile netpage_t np1 __attribute__ ((section(".gpr.np1")));volatile netpage_t np2 __attribute__ ((section(".gpr.np2")));volatile netpage_t np __attribute__ ((section(".gpr.np")));volatile u8_t np_off __attribute__ ((section(".gpr.np_off")));int nb1_start,nb1_end,nb2_start,nb2_end;void t_port_init(){	//port_dir( TX_DATA_PORT , DIR_ALL_INPUTS );	//pin_dir_in( RB , 7 );	//pin_dir_out( RE , 2 );	//pin_dir_out( RE , 1 );	//pin_high(RE,2);		asm("		setb inted, 7 ; (INTED)set CLK pin to falling edge trigger		nop		nop		clrb intf, 7 ; (INTF)clear int flag register		nop		nop		setb inte, 7 ; (INTE)enable, IRQ, interrupt		nop		nop		;setb XCFG,7	");	//led=0;		}/*void isr_getts(void) __attribute__ ((naked, section(".isr.inline")));void isr_getts(void){		asm("			snb inte, 7 ; Int enabled?		sb intf, 7 ; Int flag set?		jmp _my_isr_end ; no IRQ		clrb intf, 7		;setb REOUT,1	");		asm("_my_isr_end:");			 	}*//*void isr_tmr(void) __attribute__ ((naked, section(".isr.tmr.inline")));void isr_tmr(void){	asm("		mov 	w,_np_off		sub	w,#188		snz		jmp	_wnp_end				push 	ADDRSEL		mov	w, #7   ;APP_ADDRSEL_DST		mov	ADDRSEL, w		clr	ADDRX		mov 	w,_np		mov     ADDRH,w		mov 	w,_np_off		mov     ADDRL,w		iread		mov 	w,_np_off		sb	ADDRL, 0		mov	DATAH,w		snb	ADDRL, 0		mov	DATAL,w		iwrite		pop	ADDRSEL		inc 	_np_off				_wnp_end:		"); }*//*void led_callback(void *app){	oneshot_attach(&led_timer, TICK_RATE/10, led_callback, 0);}*/event_callback_t udpsend_event(void *app, void *param) __attribute__ ((section (".pram.udpsend_event")));event_callback_t udpsend_event(void *app, void *param){	//struct netbuf *nb_tmp;	if((npst&3)==0)return NULL;		if(npst&1)//nb1	{		npst&=0xfe;		nb=nb1;		netbuf_set_start(nb,nb1_start);		netbuf_set_end(nb,nb1_end);		netbuf_set_pos(nb, nb1_start);	}	else	{		npst&=0xfd;		nb=nb2;		netbuf_set_start(nb,nb2_start);		netbuf_set_end(nb,nb2_end);		netbuf_set_pos(nb,nb2_start);	}				udp_send_netbuf(us, eii, 			0x0a556b01, 1000, 0,0, 			UDP_TTL_DEFAULT , UDP_TOS_DEFAULT , UDP_ID_DEFAULT , UDP_DF_DEFAULT , 			nb); 						return NULL;		}/* * init() */void init(void){	debug_init();	heap_add((addr_t)(&_bss_end), (addr_t)(RAMEND - (DEFAULT_STACK_SIZE - 1)) - (addr_t)(&_bss_end));		//t_port_init();		netpage_init();		nb1=netbuf_alloc_with_fwd_space(255);	nb2=netbuf_alloc_with_fwd_space(255);	nb1_start=netbuf_get_start(nb1);	nb1_end=nb1_start+188;	nb2_start=netbuf_get_start(nb2);	nb2_end=nb2_start+188;	np1=nb1->pages[0];	np2=nb2->pages[0];	np=np1;	npst=0x04;//np1 active	np_off=0;		timer_init();				us = udp_socket_alloc(NULL);		struct ethdev_instance *edi = ip2k_eth_instance_alloc(mac_addr);	struct eth_mux_instance *ethi = eth_mux_instance_alloc((struct ethdev_instance *)edi);	eii=eth_ip_arp_instance_alloc(ethi, ETH_LOCAL_IP_ADDRESS, ETH_LOCAL_IP_SUBNET);		event_register(system_event_poll, (event_callback_t)udpsend_event, NULL);}/* * start() *	The system has been initialised and is ready to start. */void start(void){	/*	 * Instead of calling the attach method here, we call the callback to	 * kick off the timer.	 */}

⌨️ 快捷键说明

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