/** * @brief Initializes the lwIP stack * @param None * @retval None */ void lwip_sys_init(void) { struct ip_addr ipaddr; struct ip_addr netmask; struct ip_addr gw; uprintf_set_enable(UPRINT_INFO, UPRINT_BLK_NET, 1); uprintf_set_enable(UPRINT_DEBUG, UPRINT_BLK_NET, 0); /* Create tcp_ip stack thread */ tcpip_init( NULL, NULL ); /* IP address setting & display on STM32_evalboard LCD*/ #ifdef USE_DHCP ipaddr.addr = 0; netmask.addr = 0; gw.addr = 0; /* create a timer to start dhcp */ sys_timeout(2000, lwip_dhcp_start, &xnetif); #else IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3); IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3); IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3); uprintf(UPRINT_INFO, UPRINT_BLK_NET, "LWIP eth0 IP: %d.%d.%d.%d\n", IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3); #endif /* - netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw, void *state, err_t (* init)(struct netif *netif), err_t (* input)(struct pbuf *p, struct netif *netif)) Adds your network interface to the netif_list. Allocate a struct netif and pass a pointer to this structure as the first argument. Give pointers to cleared ip_addr structures when using DHCP, or fill them with sane numbers otherwise. The state pointer may be NULL. The init function pointer must point to a initialization function for your ethernet netif interface. The following code illustrates it's use.*/ netif_add(&xnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input); /* Registers the default network interface. */ netif_set_default(&xnetif); /* When the netif is fully configured this function must be called.*/ netif_set_up(&xnetif); /* attach ethernet isr */ bsp_isr_attach(16+ETH_IRQn, ethernetif_isr); bsp_irq_unmask(16+ETH_IRQn); }
/* * init PC tty * this function must run after tty_init() */ void tty_pc_init() { bsp_isr_attach(KEYB_IRQ, isr_keyboard); bsp_irq_unmask(KEYB_IRQ); if(tty_register("ttypc", &sys_tty_ldisc_default, &tty_pc_driver) == 0) kprintf("tty 'ttypc' register failed\n"); if(tty_fw_open("ttypc", 0) == NULL) { kprintf("open tty 'ttypc' failed\n"); kprintf("tty 0 name: %s\n", systty[0].name); } }
void console_init() { task_t tt; mbox_initialize(&console_mbox, 1, CBUF_SIZE, console_cbuf); bsp_isr_attach(INTSRC_UART0, serial_isr_func); bsp_irq_unmask(INTSRC_UART0); tt = task_create("tconsole", console_task, NULL, NULL, TCONSOLE_STACK_SIZE, TCONSOLE_PRIORITY, 20, 0); assert(tt != -1); task_resume_noschedule(tt); }
int hw_intr_unmask(int irq){ bsp_irq_unmask(irq); }