/** * @brief Initializes build two tasks. * @param None * @retval None */ void ICACHE_FLASH_ATTR at_init(void) { system_os_task(at_recvTask, at_recvTaskPrio, at_recvTaskQueue, at_recvTaskQueueLen); // system_os_task(at_busyTask, at_busyTaskPrio, at_busyTaskQueue, at_busyTaskQueueLen); system_os_task(at_procTask, at_procTaskPrio, at_procTaskQueue, at_procTaskQueueLen); }
void dispatch_init1(void) { flash_sector_buffer_use = fsb_free; system_os_task(uart_task, uart_task_id, uart_task_queue, uart_task_queue_length); system_os_task(command_task, command_task_id, command_task_queue, command_task_queue_length); system_os_task(timer_task, timer_task_id, timer_task_queue, timer_task_queue_length); }
void user_init(void) { //gpio_init(); uart_init(BIT_RATE_115200, BIT_RATE_115200); int at_wifiMode = wifi_get_opmode(); uart0_sendStr("\r\nCustom Server\r\n"); wifi_set_opmode( 2 ); //We broadcast our ESSID, wait for peopel to join. pTcpServer = (struct espconn *)os_zalloc(sizeof(struct espconn)); pTcpServer->type = ESPCONN_TCP; pTcpServer->state = ESPCONN_NONE; pTcpServer->proto.tcp = (esp_tcp *)os_zalloc(sizeof(esp_tcp)); pTcpServer->proto.tcp->local_port = PORT; espconn_regist_connectcb(pTcpServer, at_tcpserver_listen); espconn_accept(pTcpServer); espconn_regist_time(pTcpServer, SERVER_TIMEOUT, 0); printf("Hello, world. Starting server.\n" ); InitDumbcraft(); os_sprintf( my_server_name, "ESP8266Dumb" ); system_os_task(at_procTask, at_procTaskPrio, at_procTaskQueue, at_procTaskQueueLen); uart0_sendStr("\r\nCustom Server\r\n"); system_os_post(at_procTaskPrio, 0, 0 ); }
//Init function void ICACHE_FLASH_ATTR user_init() { // Initialize the GPIO subsystem. gpio_init(); //Set GPIO2 to output mode PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); //Set GPIO2 low gpio_output_set(0, BIT2, BIT2, 0); //Disarm timer os_timer_disarm(&some_timer); //Setup timer os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL); //Arm the timer //&some_timer is the pointer //1000 is the fire time in ms //0 for once and 1 for repeating os_timer_arm(&some_timer, 50, 1); //Start os task system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); }
void user_init(void) { ETS_UART_INTR_DISABLE(); UART_SetBaudrate(UART0, BIT_RATE_9600); UART_ResetFifo(UART0); UART_SetBaudrate(UART1, BIT_RATE_115200); UART_ResetFifo(UART1); flash_param_init(); flash_param = flash_param_get(); emsRxBuf = allocateRcvMsgBuff(); uart_init(BIT_RATE_9600, BIT_RATE_115200); rtc_clock_calibration = system_rtc_clock_cali_proc(); // get RTC clock period os_printf("rtc_clock_calibration: %0x\n", rtc_clock_calibration >>12 ); os_printf("system_get_rtc_time: %d\n", system_get_rtc_time()); os_printf("system_get_time: %d\n", system_get_time()); serverInit(flash_param->port); wifi_set_sleep_type(LIGHT_SLEEP_T); system_os_task(recvTask, recvTaskPrio, recvTaskQueue, recvTaskQueueLen); ETS_UART_INTR_ENABLE(); }
//Init function void ICACHE_FLASH_ATTR user_init(void) { scan_complete = true; // Configure the UART0 and UART1 (TX only) to 9600 uart_init(BIT_RATE_115200,BIT_RATE_115200); //Set station mode wifi_set_opmode_current( STATION_MODE ); //Disarm timer os_timer_disarm(&trilaterate_timer); //Setup timer os_timer_setfn(&trilaterate_timer, (os_timer_func_t *)scanner, NULL); //&trilaterate_timer is callback //delay in ms //0 for once and 1 for repeating //This callback timer value can't be too small as a new scan will start before the previous finishes. //The callback function checks if the scan is complete before starting a new scan. os_timer_arm(&trilaterate_timer, 10, 1); //100Hz //Start os task system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); }
//Init function void ICACHE_FLASH_ATTR user_init() { // Set up serial logging uart_div_modify(0, UART_CLK_FREQ / 115200); // Set GPIO 16 (reset GPIO) to high gpio_init(); WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); // mux configuration for XPD_DCDC to output rtc_gpio0 WRITE_PERI_REG(RTC_GPIO_CONF, (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); //mux configuration for out enable WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1); //out enable WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(1)); //Disarm timer os_timer_disarm(&some_timer); //Setup timer os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL); // Set the timer for 10s os_timer_arm(&some_timer, 10000, 1); os_printf("Resetting in 10s ...\n"); //Start os task system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); }
void user_init(void) { //Init uart uart_init(BIT_RATE_115200, BIT_RATE_115200); os_delay_us(1000); ets_uart_printf("Booting...\r\n"); // i2c i2c_init(); if(!eeprom_writeByte(0x78,0x01,0x00)) ets_uart_printf("Write failed\n\r"); //Disarm timer os_timer_disarm(&sensor_timer); //Setup timer os_timer_setfn(&sensor_timer, (os_timer_func_t *)sensor_timerfunc, NULL); //Arm timer for every 10 sec. os_timer_arm(&sensor_timer, 5000, 1); system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); }
//Init function void ICACHE_FLASH_ATTR user_init() { // uart_init(BIT_RATE_115200, BIT_RATE_115200); os_printf("Blinky, SDK version:%s\n", system_get_sdk_version()); gdb_stub_init(); // Initialize the GPIO subsystem. gpio_init(); //Set GPIO2 to output mode PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); //Set GPIO2 low gpio_output_set(0, BIT2, BIT2, 0); //Disarm timer os_timer_disarm(&some_timer); //Setup timer os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL); //Arm the timer //&some_timer is the pointer //1000 is the fire time in ms //0 for once and 1 for repeating os_timer_arm(&some_timer, 1000, 1); //Start os task system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); gdb_breakpoint(); }
//Init function void ICACHE_FLASH_ATTR user_init() { disk_initialize(MMC); //Start os task system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); }
/** @brief Serial Bridge task initialize @param[in] port: network port */ MEMSPACE bridge_task_init(int port) { static struct espconn esp_data_config; static esp_tcp esp_data_tcp_config; if(!(uart_send_queue = queue_new(BUFFER_SIZE))) reset(); if(!(uart_receive_queue = queue_new(BUFFER_SIZE))) reset(); if(!(tcp_data_send_buffer = malloc(BUFFER_SIZE))) reset(); wifi_set_sleep_type(NONE_SLEEP_T); tcp_accept(&esp_data_config, &esp_data_tcp_config, port, tcp_data_connect_callback); espconn_regist_time(&esp_data_config, 0, 0); esp_data_tcp_connection = 0; system_os_task(bridge_task, bridge_task_id, bridge_task_queue, bridge_task_queue_length); system_os_post(bridge_task_id, 0, 0); printf("\nbridge task init done\n"); }
void mg_ev_mgr_init(struct mg_mgr *mgr) { DBG(("%p Mongoose init, tq %p", mgr, s_mg_task_queue)); system_os_task(mg_lwip_task, MG_TASK_PRIORITY, s_mg_task_queue, MG_TASK_QUEUE_LEN); os_timer_setfn(&s_poll_tmr, mg_poll_timer_cb, mgr); os_timer_arm(&s_poll_tmr, MG_POLL_INTERVAL_MS, 1 /* repeat */); }
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); }
/*** Main function ***/ void ICACHE_FLASH_ATTR user_init() { uart_div_modify(0, UART_CLK_FREQ / BAUD); os_printf("Startup from %d...\r\n", system_get_rst_info()->reason); gpio_init(); ap_init(); // HTTPD espFsInit((void*)(webpages_espfs_start)); httpdInit(builtInUrls, 80); // Set GPIO2 (DCF77 pin) to input, disable pullup gpio_output_set(0, 0, 0, 2); PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO2_U); // DCF77 read timer os_timer_disarm(&dcf_read_timer); os_timer_setfn(&dcf_read_timer, (os_timer_func_t *) dcf_read_timer_cb, NULL); os_timer_arm(&dcf_read_timer, 5, 1); // Second increase timer os_timer_disarm(&time_inc_timer); os_timer_setfn(&time_inc_timer, (os_timer_func_t *) time_inc_timer_cb, NULL); os_timer_arm(&time_inc_timer, 1000, 1); // DCF77 decode timer: decide wheter 1 or 0 dcf_decode_timer_adjust(); os_printf(" completed!\r\n\r\n"); system_os_task(loop, user_procTaskPrio, user_procTaskQueue, user_procTaskQueueLen); system_os_post(user_procTaskPrio, 0, 0); }
// WiFi call back LOCAL void ICACHE_FLASH_ATTR wifi_cb(System_Event_t *event) { switch(event->event) { case EVENT_STAMODE_CONNECTED: os_printf("EVENT: STAMODE_CONNECTED!\n"); break; case EVENT_STAMODE_DISCONNECTED: os_printf("EVENT: STAMODE_DISCONNECTED!\n"); break; case EVENT_STAMODE_AUTHMODE_CHANGE: os_printf("EVENT: STAMODE_AUTHMODE_CHANGE\n"); break; case EVENT_STAMODE_GOT_IP: os_printf("Event: EVENT_STAMODE_GOT_IP\n"); system_os_task(connect_to_jarvis, user_procTaskPrio, user_procTaskQueue, user_procTaskQueueLen); system_os_post(user_procTaskPrio, 0, 0 ); break; case EVENT_SOFTAPMODE_STACONNECTED: os_printf("Event: EVENT_SOFTAPMODE_STACONNECTED\n"); break; case EVENT_SOFTAPMODE_STADISCONNECTED: os_printf("Event: EVENT_SOFTAPMODE_STADISCONNECTED\n"); break; default: os_printf("Unexpected event: %d\n", event->event); break; } }
void ICACHE_FLASH_ATTR init_GPIOs_intr(void) { if(GPIO_TEST1 == GPIO_TEST2 || GPIO_TEST1 > 15 || GPIO_TEST1 > 15) { GPIO_TEST1 = 4; GPIO_TEST2 = 5; } // ets_isr_mask(1 << ETS_GPIO_INUM); // запрет прерываний GPIOs // чтение пользовательских констант (0 < idx < 4) из записей в Flash GPIO_INT_Counter1 = read_user_const(1); GPIO_INT_Counter2 = read_user_const(2); system_os_task(task_GPIOs_intr, GPIOs_intr_TASK_PRIO, GPIOs_intr_taskQueue, GPIOs_intr_TASK_QUEUE_LEN); uint32 pins_mask = (1<<GPIO_TEST1) | (1<<GPIO_TEST2); gpio_output_set(0,0,0, pins_mask); // настроить GPIOx на ввод set_gpiox_mux_func_ioport(GPIO_TEST1); // установить функцию GPIOx в режим порта i/o set_gpiox_mux_func_ioport(GPIO_TEST2); // установить функцию GPIOx в режим порта i/o // GPIO_ENABLE_W1TC = pins_mask; // GPIO OUTPUT DISABLE отключить вывод в портах ets_isr_attach(ETS_GPIO_INUM, GPIOs_intr_handler, NULL); gpio_pin_intr_state_set(GPIO_TEST1, GPIO_PIN_INTR_ANYEDGE); // GPIO_PIN_INTR_POSEDGE | GPIO_PIN_INTR_NEGEDGE ? gpio_pin_intr_state_set(GPIO_TEST2, GPIO_PIN_INTR_ANYEDGE); // GPIO_PIN_INTR_POSEDGE | GPIO_PIN_INTR_NEGEDGE ? // разрешить прерывания GPIOs GPIO_STATUS_W1TC = pins_mask; ets_isr_unmask(1 << ETS_GPIO_INUM); GPIO_INTR_INIT = 1; GPIO_INT_init_flg = 1; os_printf("GPIOs_intr init (%d,%d) ", GPIO_TEST1, GPIO_TEST2); }
void ICACHE_FLASH_ATTR user_init() { void* p; uint32 now,diff; //~ system_timer_reinit(); //US_TIMER uart_init(BIT_RATE_115200, BIT_RATE_115200); os_printf("\n\nESP8266 IRMP Test v0.3 W.Strobl 20151120\n"); os_printf("F_INTERRUPTS==%d\n",F_INTERRUPTS); sysinfo(); hw_timer_init(NMI_SOURCE,1); hw_timer_set_func(irmp_timer); hw_timer_arm (1000000/F_INTERRUPTS); // Initialize the GPIO subsystem. gpio_init(); irmp_init (); //Start os task system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); system_os_post(user_procTaskPrio, 0, 0 ); os_printf("IRMP listening ...\n"); }
void MQTT_InitClient(MQTT_Client *mqttClient, uint8_t* client_id, uint8_t* client_user, uint8_t* client_pass, uint32_t keepAliveTime) { //spam INFO("MQTT_InitClient\r\n"); os_memset(&mqttClient->connect_info, 0, sizeof(mqtt_connect_info_t)); mqttClient->connect_info.client_id = client_id; mqttClient->connect_info.username = client_user; mqttClient->connect_info.password = client_pass; mqttClient->connect_info.keepalive = keepAliveTime; mqttClient->connect_info.clean_session = 1; //mqttClient->mqtt_state = (mqtt_state_t *)os_zalloc(sizeof(mqtt_state_t)); mqttClient->mqtt_state.in_buffer = (uint8_t *)os_zalloc(MQTT_BUF_SIZE); mqttClient->mqtt_state.in_buffer_length = MQTT_BUF_SIZE; mqttClient->mqtt_state.out_buffer = (uint8_t *)os_zalloc(MQTT_BUF_SIZE); mqttClient->mqtt_state.out_buffer_length = MQTT_BUF_SIZE; mqttClient->mqtt_state.connect_info = &mqttClient->connect_info; mqttClient->keepAliveTick = 0; mqttClient->reconnectTick = 0; os_timer_disarm(&mqttClient->mqttTimer); os_timer_setfn(&mqttClient->mqttTimer, (os_timer_func_t *)mqtt_timer, mqttClient); os_timer_arm(&mqttClient->mqttTimer, 1000, 1); QUEUE_Init(&mqttClient->msgQueue, QUEUE_BUFFER_SIZE); system_os_task(MQTT_Task, MQTT_TASK_PRIO, mqtt_procTaskQueue, MQTT_TASK_QUEUE_SIZE); system_os_post(MQTT_TASK_PRIO, 0, (os_param_t)mqttClient); }
//Init function void ICACHE_FLASH_ATTR user_init() { uart_init(115200, 115200); os_delay_us(100); uart0_sendStr("*** Monitor mode test ***\r\n"); os_printf(" -> Promisc mode setup ... "); wifi_set_promiscuous_rx_cb(promisc_cb); wifi_promiscuous_enable(1); os_printf("done.\n"); os_printf(" -> Timer setup ... "); os_timer_disarm(&channelHop_timer); os_timer_setfn(&channelHop_timer, (os_timer_func_t *) channelHop, NULL); os_timer_arm(&channelHop_timer, CHANNEL_HOP_INTERVAL, 1); os_printf("done.\n"); os_printf(" -> Set opmode ... "); wifi_set_opmode( 0x1 ); os_printf("done.\n"); //Start os task system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); os_printf(" -> Init finished!\n\n"); }
void user_init(void) { uart_init(BIT_RATE_115200, BIT_RATE_115200); int at_wifiMode = wifi_get_opmode(); uart0_sendStr("\r\nCustom Server\r\n"); wifi_set_opmode( 2 ); //We broadcast our ESSID, wait for peopel to join. pUdpServer = (struct espconn *)os_zalloc(sizeof(struct espconn)); if (pUdpServer == NULL) { uart0_sendStr("UdpServer Failure\r\n"); return; } pUdpServer->type = ESPCONN_UDP; pUdpServer->state = ESPCONN_NONE; pUdpServer->proto.udp = (esp_udp *)os_zalloc(sizeof(esp_udp)); pUdpServer->proto.udp->local_port = PORT; pUdpServer->reverse = NULL; espconn_regist_recvcb(pUdpServer, at_udpserver_recv); espconn_accept(pUdpServer); char outbuffer[] = { 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff }; WS2812OutBuffer( outbuffer, sizeof(outbuffer) ); system_os_task(at_procTask, at_procTaskPrio, at_procTaskQueue, at_procTaskQueueLen); uart0_sendStr("\r\nCustom Server\r\n"); system_os_post(at_procTaskPrio, 0, 0 ); }
void ICACHE_FLASH_ATTR CMD_Init() { INFO("CMD: INIT\r\n"); RINGBUF_Init(&rxRb, rxBuf, sizeof(rxBuf)); PROTO_Init(&rxProto, protoCompletedCb, protoRxBuf, sizeof(protoRxBuf)); system_os_task(CMD_Task, CMD_TASK_PRIO, cmdRecvQueue, CMD_TASK_QUEUE_SIZE); system_os_post(CMD_TASK_PRIO, 0, 0); }
void serialInit(void) { // Initialize the serial port for USB serial bridge uartInit(115200, 115200); // TURN_OFF_SYSTEM_MESSAGES(); TURN_ON_SYSTEM_MESSAGES(); system_os_task(taskHandler, USER_TASK_PRIO_0, taskQueue, taskQueueLen); // DISPLAY_MENU(); DISPLAY_MENU_W_SPI(); }
void ICACHE_FLASH_ATTR user_init(void) { system_update_cpu_freq(160); i2c_init(); display_init(0x3c); system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); system_os_post(user_procTaskPrio, 0, 0); }
void ICACHE_FLASH_ATTR user_init() { // Initialize gpio_init(); uart_init(2400, 2400); os_delay_us(10000); //print("\r\n:)\r\n"); if (0 && DEBUG) { wifi_station_disconnect(); wifi_station_dhcpc_stop(); } //setup_server(); // ------------------------------------------------------------------------- ets_uart_printf("S"); //Set GPIO2 to output mode PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); //Set GPIO2 low gpio_output_set(0, BIT2, BIT2, 0); //Disarm timer os_timer_disarm(&check_timer); //Setup timer os_timer_setfn(&check_timer, (os_timer_func_t *)check_timerfunc, NULL); //Arm the timer //1000 is the fire time in ms //0 for once and 1 for repeating os_timer_arm(&check_timer, 5000, 1); // Start going //Start os task system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); system_os_task(recvTask, recvTaskPrio, recvTaskQueue, recvTaskQueueLen); system_init_done_cb(init_done); }
//Main routine. Initialize stdout, the I/O and the webserver and we're done. void user_init(void) { uart_init(); ioInit(); websocketdInit(8080, &onWsConnection); //Start os task system_os_task(rxLoop, RX_PRIO, user_procTaskQueue, RX_QUEUE_LEN); system_os_post(RX_PRIO, 0, 0 ); os_printf("\nReady\n"); }
//Init function void ICACHE_FLASH_ATTR user_init() { // Initialize UART0 uart_div_modify(0, UART_CLK_FREQ / 9600); //Set up the hello world task system_os_task(task_hello, user_procTaskPrio, user_procTaskQueue, user_procTaskQueueLen); //send a message to the "hello world" task to activate it system_os_post(user_procTaskPrio, 0, 0 ); }
void ICACHE_FLASH_ATTR user_init(void) { #ifdef DEBUG_SERIAL uart_init(BIT_RATE_115200,BIT_RATE_115200); system_set_os_print(TRUE); #else system_set_os_print(FALSE); #endif //Create task for main loop system_os_task(ost_loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); system_os_post(user_procTaskPrio, 0, 0 ); //Create task for the WiFi setup system_os_task(ost_wifi_setup, 1,user_procTaskQueue, user_procTaskQueueLen); system_os_post(1, 0, 0 ); //Create task for the WiFi networks scan system_os_task(ost_wifi_scan, 2,user_procTaskQueue, user_procTaskQueueLen); system_os_post(2, 0, 0 ); }
static void ICACHE_FLASH_ATTR startUp() { TESTP("\n%s ( %s - %s ) starting ...\n", "MQTT Bridge", wifi_station_get_hostname(), version); INFOP("wifi_get_phy_mode = %d\n", wifi_get_phy_mode()); // os_timer_disarm(&uartTimer); // os_timer_setfn(&uartTimer, (os_timer_func_t *) uartTimerCb, (void *) 0); // os_timer_arm(&uartTimer, 10 * 1000, true); if ( !system_os_task(backgroundTask, USER_TASK_PRIO_1, taskQueue, QUEUE_SIZE)) ERRORP("Can't set up background task\n"); lastAction = INIT_DONE; }
void user_init(void) { uart_init(BIT_RATE_115200, BIT_RATE_115200); uart0_sendStr("\r\nesp8266 ws2812 driver\r\n"); // int opm = wifi_get_opmode(); // if( opm == 1 ) need_to_switch_opmode = 120; // wifi_set_opmode_current(2); //Uncomment this to force a system restore. // system_restore(); CSSettingsLoad( 0 ); CSPreInit(); pUdpServer = (struct espconn *)os_zalloc(sizeof(struct espconn)); ets_memset( pUdpServer, 0, sizeof( struct espconn ) ); espconn_create( pUdpServer ); pUdpServer->type = ESPCONN_UDP; pUdpServer->proto.udp = (esp_udp *)os_zalloc(sizeof(esp_udp)); pUdpServer->proto.udp->local_port = 7777; espconn_regist_recvcb(pUdpServer, udpserver_recv); if( espconn_create( pUdpServer ) ) { while(1) { uart0_sendStr( "\r\nFAULT\r\n" ); } } CSInit(); SetServiceName( "ws2812" ); AddMDNSName( "cn8266" ); AddMDNSName( "ws2812" ); AddMDNSService( "_http._tcp", "An ESP8266 Webserver", 80 ); AddMDNSService( "_ws2812._udp", "WS2812 Driver", 7777 ); AddMDNSService( "_cn8266._udp", "ESP8266 Backend", 7878 ); //Add a process system_os_task(procTask, procTaskPrio, procTaskQueue, procTaskQueueLen); //Timer example os_timer_disarm(&some_timer); os_timer_setfn(&some_timer, (os_timer_func_t *)myTimer, NULL); os_timer_arm(&some_timer, 100, 1); ws2812_init(); uint8_t ledout[] = { 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00 }; ws2812_push( ledout, sizeof( ledout ) ); system_os_post(procTaskPrio, 0, 0 ); }
//Init function void ICACHE_FLASH_ATTR user_init() { uart_init(BIT_RATE_115200, BIT_RATE_115200); os_delay_us(100000); wifiInit(); //Start os task system_os_task(loop, user_procTaskPrio, user_procTaskQueue, user_procTaskQueueLen); system_os_post(user_procTaskPrio, 0, 0); }