?? main_b1.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 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(np_off<188)return NULL; nb_tmp=nb; if(nb==nb1) { netbuf_set_start(nb,nb1_start); netbuf_set_end(nb,nb1_end); netbuf_set_pos(nb, nb1_start); nb=nb2; } else { netbuf_set_start(nb,nb2_start); netbuf_set_end(nb,nb2_end); netbuf_set_pos(nb,nb2_start); nb=nb1; } np=nb->pages[0]; np_off=0; udp_send_netbuf(us, eii, 0x0a556b01, 1000, 0,0, UDP_TTL_DEFAULT , UDP_TOS_DEFAULT , UDP_ID_DEFAULT , UDP_DF_DEFAULT , nb_tmp); 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)); timer_init(); //t_port_init(); netpage_init(); nb1=netbuf_alloc_with_fwd_space(188); nb2=netbuf_alloc_with_fwd_space(188); nb1_start=netbuf_get_start(nb1); nb1_end=nb1_start+188; nb2_start=netbuf_get_start(nb2); nb2_end=nb2_start+188; /*nb1=netbuf_alloc_with_fwd_space(255); nb2=netbuf_alloc_with_fwd_space(255); nb1_start=netbuf_get_start(nb1)+56; nb1_end=nb1_start+188; nb2_start=netbuf_get_start(nb2)+56; nb2_end=nb2_start+188;*/ nb=nb1; np=nb->pages[0]; np_off=0; 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. */}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -