Exemple #1
0
void ICACHE_FLASH_ATTR
user_init(void)
{
	gpio_init();
	gpio_output_set(0, 0, 0, 0xFFFFFFFF);

	//init software uart
	Softuart_SetPinRx(&softuart,13); 	
	Softuart_SetPinTx(&softuart,15);

	gpio_pin_wakeup_disable();
	PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U,FUNC_GPIO12);

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


	//clear noise
	uart0_sendStr("\r\n\r\n\r\n");

	//wifi_set_phy_mode(3);
	system_phy_set_powerup_option(3);
	wifi_set_opmode(STATION_MODE); //Set station mode
	system_phy_set_max_tpw(82); //MAX POWERR!
	system_phy_set_tpw_via_vdd33(system_get_vdd33());
	user_set_station_config();

	os_timer_disarm(&init_timer);
	os_timer_setfn(&init_timer, (os_timer_func_t *)gps_uart_init, NULL);
	os_timer_arm(&init_timer, 1000, 0); 
}
Exemple #2
0
void ICACHE_FLASH_ATTR user_init()
{
    // Initialize the GPIO subsystem.
    //UART_init(BIT_RATE_115200, BIT_RATE_115200, 0);
    //UART_SetPrintPort(UART0);
    stdout_init();

    i2c_master_gpio_init();

    user_set_station_config();

    pcf8754_i2c_write_byte(I2C_INPUT_ADDRESS, 0);
    // =================================================
    // Initialize GPIO2 and GPIO0 as GPIO
    // =================================================
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_GPIO3);
    PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0RXD_U);

    gpio_output_set(0, 0, 0, GPIO_ID_PIN(3)); // set set gpio 0 as input

    ETS_GPIO_INTR_DISABLE();
    // Attach interrupt handle to gpio interrupts.
    ETS_GPIO_INTR_ATTACH(gpio_intr_handler, NULL);
    GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(3)); // clear gpio status
    gpio_pin_intr_state_set(GPIO_ID_PIN(3), GPIO_PIN_INTR_ANYEDGE); // clear gpio status.
    ETS_GPIO_INTR_ENABLE(); // Enable interrupts by GPIO


	// register a callback function to let user code know that system
	// initialization is complete
	system_init_done_cb(&post_user_init_func);

    //Start os task
    system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
}
/*
 * 函数:user_wifi_init
 * 说明:WiFi配置初始化
 */
void ICACHE_FLASH_ATTR
user_wifi_init(void)
{
	wifi_set_opmode(STATION_MODE);
	user_set_station_config(WIFI_SSID, WIFI_PASSWORD);
    wifi_set_event_handler_cb(wifi_handle_event_cb);
}
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void user_init(void)
{
    os_printf("SDK version:%s\n", system_get_sdk_version());
   
    //Set station mode 
    wifi_set_opmode(STATION_MODE); 

    //ESP8266 connect to router
    user_set_station_config();
}
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void user_init(void)
{

    uart_init(115200, 115200);

    UART_SetPrintPort(0);


    os_printf("init start, SDK version:%s\n", system_get_sdk_version());

    os_sprintf("vicly rom 20150109001");



   //Set softAP + station mode
   wifi_set_opmode(STATIONAP_MODE);

   // ESP8266 connect to router.
    user_set_station_config();


    /*
    static os_timer_t myuart_test_timer;
	os_timer_disarm(&myuart_test_timer);
	//os_timer_setfn(&myuart_test_timer, (os_timer_func_t *)vtest_uart, NULL);
	os_sprintf("os_sprintf:vicly test os time...;;");
	PRINTF("timer:PRINTF:uart0_sendStr q1  ... \n");
	os_timer_arm(&myuart_test_timer, 15000, 1);   //call set_usart_gpu_content 15sec each
*/


    /*
    //---------------smart config------------------s
//    os_printf("SDK version:%s\n", system_get_sdk_version());
	///smartconfig_set_type(SC_TYPE_ESPTOUCH); //SC_TYPE_ESPTOUCH,SC_TYPE_AIRKISS,SC_TYPE_ESPTOUCH_AIRKISS
	//smartconfig_set_type(SC_TYPE_AIRKISS); //SC_TYPE_ESPTOUCH,SC_TYPE_AIRKISS,SC_TYPE_ESPTOUCH_AIRKISS
	smartconfig_set_type(SC_TYPE_ESPTOUCH); //SC_TYPE_ESPTOUCH,SC_TYPE_AIRKISS,SC_TYPE_ESPTOUCH_AIRKISS

	wifi_set_opmode(STATION_MODE);
    smartconfig_start(smartconfig_done);
    //---------------smart config------------------e
*/


///#if ESP_PLATFORM
    /*Initialization of the peripheral drivers*/
    /*For light demo , it is user_light_init();*/
    /* Also check whether assigned ip addr by the router.If so, connect to ESP-server  */
///    user_esp_platform_init();
///#endif
    /*Establish a udp socket to receive local device detect info.*/
    /*Listen to the port 1025, as well as udp broadcast.
    /*If receive a string of device_find_request, it rely its IP address and MAC.*/
///    user_devicefind_init();







user_esp_platform_init();
///	v_user_esp_platform_init();

    /*Establish a TCP server for http(with JSON) POST or GET command to communicate with the device.*/
    /*You can find the command in "2B-SDK-Espressif IoT Demo.pdf" to see the details.*/
    /*the JSON command for curl is like:*/
    /*3 Channel mode: curl -X POST -H "Content-Type:application/json" -d "{\"period\":1000,\"rgb\":{\"red\":16000,\"green\":16000,\"blue\":16000}}" http://192.168.4.1/config?command=light      */
    /*5 Channel mode: curl -X POST -H "Content-Type:application/json" -d "{\"period\":1000,\"rgb\":{\"red\":16000,\"green\":16000,\"blue\":16000,\"cwhite\":3000,\"wwhite\",3000}}" http://192.168.4.1/config?command=light      */

    /*
#ifdef SERVER_SSL_ENABLE
    user_webserver_init(SERVER_SSL_PORT);
#else
    user_webserver_init(SERVER_PORT);
#endif
*/

}