void ICACHE_FLASH_ATTR user_init(void) { wifi_init(); uart_init_new(); tcp_shell_init(); UART_SetPrintPort( debugPort ); xTaskCreate( forthright_task, "forthright", 256, NULL, 2, &tasks[0] ); // create root FORTH interpreter }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { printf("SDK version:%s\n", system_get_sdk_version()); uart_init_new(); xTaskCreate(my_task, "my_task", 128, NULL, 4, NULL); }
void ICACHE_FLASH_ATTR user_uart_dev_start(void) { uart_init_new(); // cfg uart0 connection device MCU, cfg uart1 TX debug output createQueue(5); //串口发送缓冲队列长度 xQueueCusUart = xQueueCreate((unsigned portBASE_TYPE)CUS_UART0_QUEUE_LENGTH, sizeof(CusUartIntrPtr)); xTaskCreate(user_uart_task, (uint8 const *)"uart", 256, NULL, tskIDLE_PRIORITY + 2, NULL); return; }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { bool ret; PIN_FUNC_SELECT(LED_GPIO_MUX, LED_GPIO_FUNC); xUARTQueue = xQueueCreate(128, sizeof(char)); uart_init_new(); UART_intr_handler_register(&uart0_rx_intr_handler, &xUARTQueue); ETS_UART_INTR_ENABLE(); printf("SDK version:%s\n", system_get_sdk_version()); GPIO_OUTPUT_SET(LED_GPIO, 0); //Set station mode wifi_set_opmode(STATIONAP_MODE); // ESP8266 connect to router. // user_set_station_config(); // Setup TCP server wifi_station_set_auto_connect(0); // wifi_station_set_reconnect_policy(0); printf("Wifi Button example program. \r\n"); if (!read_user_config(&user_config)) { ret = wifi_set_opmode(STATIONAP_MODE); DBG("wifi_set_opmode returns %d op_mode now %d\r\n", ret, wifi_get_opmode()); // user_set_station_config(); user_tcpserver_init(SERVER_LOCAL_PORT); // user_tcpserver_init(SERVER_LOCAL_PORT); wifi_station_set_auto_connect(1); } else { printf ("No valid config\r\n"); } printf("Hiya"); // sys_init_timing(); lwip_init(); // while(1); // xTaskCreate(check_input, "input", 256, &xUARTQueue, 3, NULL); // xTaskCreate(helloworld, "hw", configMINIMAL_STACK_SIZE, NULL, 2, NULL); // xTaskCreate(blinky, "bl", configMINIMAL_STACK_SIZE, NULL, 2, NULL); }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { #ifdef DOUBLE_CLK_FREQ system_update_cpu_freq(160); #endif #ifdef DEV //system_uart_swap(); #endif uart_init_new(BAUD, uart_rx); DBG("WILOC-MASTER"); printf("SDK version:%s\n", system_get_sdk_version()); unsigned char mac[6]; wifi_get_macaddr(STATION_IF, mac); printf("MAC-STA:"); printmac(mac, 0); printf("\n"); wifi_get_macaddr(SOFTAP_IF, mac); printf("MAC- AP:"); printmac(mac, 0); printf("\n"); DBG(" ---- set opmode"); if (!wifi_set_opmode(STATIONAP_MODE)) { DBG(" ---- > failed to set opmode"); } DBG(" ---- done"); // wifi_softap_set_config(&softapConf); os_delay_us(300); char *ssid = SSID; char *password = PASSWORD; struct station_config stationConf; stationConf.bssid_set = 0; //need not check MAC address of AP memcpy(&stationConf.ssid, ssid, strlen(ssid) + 1); memcpy(&stationConf.password, password, strlen(password) + 1); wifi_station_set_config(&stationConf); wifi_station_set_reconnect_policy(true); wifi_station_connect(); DBG(" --- trying to connect to AP"); tx_queue = xQueueCreate(1, sizeof(int)); ringbuf_mutex = xSemaphoreCreateMutex(); ringbuf_init(&ringbuf_m, tx_buffer_m, sizeof(tx_buffer_m)); ringbuf_init(&ringbuf_t, tx_buffer_t, sizeof(tx_buffer_t)); synchronize_dev_id(); // wait until wifi is connected user_wifi_init(connect_to_server); }