Ejemplo n.º 1
0
void ICACHE_FLASH_ATTR user_init(void)
{
	uint8_t i;
	//wifi_set_opmode(3); //STA+AP

	#ifdef CONFIG_DYNAMIC
		flash_param_t *flash_param;
		flash_param_init();
		flash_param = flash_param_get();
		UartDev.data_bits = GETUART_DATABITS(flash_param->uartconf0);
		UartDev.parity = GETUART_PARITYMODE(flash_param->uartconf0);
		UartDev.stop_bits = GETUART_STOPBITS(flash_param->uartconf0);
		uart_init(flash_param->baud, BIT_RATE_115200);
	#else
		UartDev.data_bits = EIGHT_BITS;
		UartDev.parity = NONE_BITS;
		UartDev.stop_bits = ONE_STOP_BIT;
		uart_init(BIT_RATE_115200, BIT_RATE_115200);
	#endif
	os_printf("size flash_param_t %d\n", sizeof(flash_param_t));


	#ifdef CONFIG_STATIC
		// refresh wifi config
		config_execute();
	#endif

	#ifdef CONFIG_DYNAMIC
		serverInit(flash_param->port);
	#else
		serverInit(23);
	#endif

	config_gpio();

    os_timer_disarm(&main_timer);
	os_timer_setfn(&main_timer, (os_timer_func_t *)main_timer_callback, NULL);
	os_timer_arm(&main_timer, TIMER_DURATION_MS, 1);

	system_os_task(recvTask, recvTaskPrio, recvTaskQueue, recvTaskQueueLen);
}
Ejemplo n.º 2
0
void user_init(void)
{
	uint8_t i;



	UartDev.data_bits = EIGHT_BITS;
	UartDev.parity = NONE_BITS;
	UartDev.stop_bits = ONE_STOP_BIT;
	uart_init(BIT_RATE_9600, BIT_RATE_9600);


	i2c_init();
	SSD1306Init();
	clearScreen();
	stringDraw(1, 1, "SDK ver:");
	stringDraw(1, 48, (char*)system_get_sdk_version());


	ets_uart_printf("reset reason: %d\n", reset_info->reason);
	ets_uart_printf("Booting...\n");
	ets_uart_printf("SDK version:%s\n", system_get_sdk_version());

	setup_wifi_st_mode();
	if(wifi_get_phy_mode() != PHY_MODE_11N)
		wifi_set_phy_mode(PHY_MODE_11N);
	if(wifi_station_get_auto_connect() == 0)
		wifi_station_set_auto_connect(1);



#ifdef CONFIG_DYNAMIC
	flash_param_t *flash_param;
	flash_param_init();
	flash_param = flash_param_get();
	UartDev.data_bits = GETUART_DATABITS(flash_param->uartconf0);
	UartDev.parity = GETUART_PARITYMODE(flash_param->uartconf0);
	UartDev.stop_bits = GETUART_STOPBITS(flash_param->uartconf0);
	uart_init(flash_param->baud, BIT_RATE_115200);
#else

#endif
	ets_uart_printf("size flash_param_t %d\n", sizeof(flash_param_t));




#ifdef CONFIG_GPIO
	config_gpio();
#endif



	//		os_timer_disarm(&timer_1);
	//		os_timer_setfn(&timer_1, (os_timer_func_t *)timer_1_int, NULL);
	//		os_timer_arm(&timer_1, 1000, 1);

	// Wait for Wi-Fi connection
	os_timer_disarm(&WiFiLinker);
	os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
	os_timer_arm(&WiFiLinker, 1000, 0);




	system_os_task(recvTask, recvTaskPrio, recvTaskQueue, recvTaskQueueLen);
}