Esempio n. 1
0
static int net_init(struct device *unused)
{
	int status = 0;

	NET_DBG("Priority %d", CONFIG_NET_INIT_PRIO);

	net_shell_init();

	net_pkt_init();

	net_context_init();

	l2_init();
	l3_init();

	net_mgmt_event_init();

	init_rx_queue();

#if CONFIG_NET_DHCPV4
	status = dhcpv4_init();
	if (status) {
		return status;
	}
#endif

	return status;
}
Esempio n. 2
0
int ieee80211_rtwmp_init(char * net_dev_name){
	int found = 0;
	net_dev = first_net_device(&init_net);
	while (net_dev) {
		net_dev = next_net_device(net_dev);
		if (strstr(net_dev->name, net_dev_name) != NULL) {
			found = 1;
			break;
		}
	}
	if (!found){
		printk(KERN_INFO "Error: unable to find net_device %s\n",net_dev_name);
		return 0;
	}

	/* Build the ethernet header used for tx */
	ethernet_header = (struct ethhdr *) ethernet_frame;
	memcpy(ethernet_header->h_source, src_mac, ETH_ALEN);
	memcpy(ethernet_header->h_dest, dst_mac, ETH_ALEN);
	ethernet_header->h_proto = htons(WMP_PROTO);

	init_rx_queue(&rx_rtwmp_queue);

	printk(KERN_INFO "Found net_device %s",net_dev->name);
	printk(KERN_INFO "MAC80211-RT-WMP initialized successfully\n");
	initialized = 1;
	return 1;

}
Esempio n. 3
0
int net_init(void)
{
	static uint8_t initialized;

	if (initialized)
		return -EALREADY;

	initialized = 1;

	net_context_init();
	net_buf_init();
	init_tx_queue();
	init_rx_queue();

#if defined (CONFIG_NETWORKING_WITH_15_4)
	net_driver_15_4_init();
#endif

	net_driver_slip_init();

	return network_initialization();
}
Esempio n. 4
0
void main(void)
{
	struct device *dev;
	u32_t baudrate, dtr = 0;
	int ret;

	dev = device_get_binding(CONFIG_CDC_ACM_PORT_NAME);
	if (!dev) {
		SYS_LOG_ERR("CDC ACM device not found");
		return;
	}

	SYS_LOG_DBG("Wait for DTR");

	while (1) {
		uart_line_ctrl_get(dev, LINE_CTRL_DTR, &dtr);
		if (dtr)
			break;
	}

	uart_dev = dev;

	SYS_LOG_DBG("DTR set, continue");

#if CONFIG_DCD_DSR
	/* They are optional, we use them to test the interrupt endpoint */
	ret = uart_line_ctrl_set(dev, LINE_CTRL_DCD, 1);
	if (ret)
		printk("Failed to set DCD, ret code %d\n", ret);

	ret = uart_line_ctrl_set(dev, LINE_CTRL_DSR, 1);
	if (ret)
		printk("Failed to set DSR, ret code %d\n", ret);

	/* Wait 1 sec for the host to do all settings */
	sys_thread_busy_wait(1000000);
#endif
	ret = uart_line_ctrl_get(dev, LINE_CTRL_BAUD_RATE, &baudrate);
	if (ret)
		printk("Failed to get baudrate, ret code %d\n", ret);
	else
		printk("Baudrate detected: %d\n", baudrate);

	SYS_LOG_INF("USB serial initialized");

	/* Initialize net_pkt */
	net_pkt_init();

	/* Initialize RX queue */
	init_rx_queue();

	/* Initialize TX queue */
	init_tx_queue();

	/* Initialize ieee802154 device */
	if (!init_ieee802154()) {
		SYS_LOG_ERR("Unable to initialize ieee802154");
		return;
	};

	uart_irq_callback_set(dev, interrupt_handler);

	/* Enable rx interrupts */
	uart_irq_rx_enable(dev);

	/* Enable tx interrupts */
	uart_irq_tx_enable(dev);
}