void user_init() { struct station_config conf; // This is used to setup the serial communication uart_div_modify(0, UART_CLK_FREQ / 115200); wifi_set_opmode(STATION_MODE); // os_bzero ( &conf, sizeof(struct station_config) ); os_memset ( &conf, 0, sizeof(struct station_config) ); os_memcpy (&conf.ssid, ssid, 32); os_memcpy (&conf.password, pass, 64 ); wifi_station_set_config (&conf); // And this is used to print some information os_printf("\n"); os_printf("SDK version:%s\n", system_get_sdk_version()); system_print_meminfo(); os_delay_us ( 1 ); os_printf ( "CPU Hz = %d\n", system_get_cpu_freq() ); show_mac (); show_ip (); /* set a callback for wifi events */ wifi_set_event_handler_cb ( wifi_event ); }
//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 ICACHE_FLASH_ATTR user_init(void) { uart_div_modify(0, UART_CLK_FREQ / BAUD); wifi_set_opmode(STATION_MODE); wifi_station_connect(); /*** I²C init ***/ i2c_master_gpio_init(); mpu9250_init(); ak8963_init(); os_delay_us(10000); i2c_scanbus(); /*** LCD Init ***/ ssd1306_init(0); ssd1306_text_small(10, 10, "Init..."); ssd1306_flip(); // ~Charge input PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13); gpio_output_set(0, 0, 0, BIT13); // Button inputs buttons_init(); ak8963_calibration_start(10000, on_ak8963_calibration); os_printf("Startup\r\n"); }
/* Init function */ void user_init() { #ifndef RTOS_TODO system_update_cpu_freq(SYS_CPU_160MHZ); system_init_done_cb(sdk_init_done_cb); #endif uart_div_modify(0, UART_CLK_FREQ / 115200); #ifndef RTOS_TODO system_set_os_print(0); #endif setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); esp_exception_handler_init(); #ifndef RTOS_TODO gpio_init(); #endif #ifdef RTOS_TODO rtos_init_dispatcher(); sdk_init_done_cb(); #endif }
/*** 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); }
void ICACHE_FLASH_ATTR at_setupCmdIpr(uint8_t id, char *pPara) { at_uartType tempUart; pPara++; tempUart.baud = atoi(pPara); if((tempUart.baud>(UART_CLK_FREQ / 16))||(tempUart.baud == 0)) { at_backError; return; } while(TRUE) { uint32_t fifo_cnt = READ_PERI_REG(UART_STATUS(0)) & (UART_TXFIFO_CNT<<UART_TXFIFO_CNT_S); if((fifo_cnt >> UART_TXFIFO_CNT_S & UART_TXFIFO_CNT) == 0) { break; } } os_delay_us(10000); uart_div_modify(0, UART_CLK_FREQ / tempUart.baud); tempUart.saved = 1; user_esp_platform_save_param((uint32 *)&tempUart, sizeof(at_uartType)); // spi_flash_read(60 * 4096, (uint32 *)&upFlag, sizeof(updateFlagType)); // // os_printf("%X\r\n",upFlag.flag); // // os_printf("%X\r\n",upFlag.reserve[0]); // // os_printf("%X\r\n",upFlag.reserve[1]); // // os_printf("%X\r\n",upFlag.reserve[2]); // upFlag.flag = 1; // spi_flash_erase_sector(60); // spi_flash_write(60 * 4096, (uint32 *)&upFlag, sizeof(updateFlagType)); // // spi_flash_read(60 * 4096, (uint32 *)&upFlag, sizeof(updateFlagType)); at_backOk; }
void user_init(void) { // Uart init uart_div_modify(0, UART_CLK_FREQ / 115200); os_printf("\nStarting...\n"); int i; for(i=0; i<MAX_CONNS; i++) { // c field is used as indicator for free/used connection slots conns[i].id = 0; } // Add page to ureq //ureq_serve("/", s_home, "GET"); ureq_serve("/get", s_get, "GET"); ureq_serve("/post", s_post, "ALL"); ureq_serve("/redirect", s_redirect, "GET"); ureq_serve("/redirected", s_redirected, "GET"); // Some gpio-related stuff gpio_init(); //Set GPIO2 to output mode PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0); PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO0_U); //Set GPIO2 high gpio_output_set(BIT0, 0, BIT0, 0); // Wifi setup wifiInit(); ssServerInit(); // Print a message that we have completed user_init on debug uart os_printf("Ready.\n"); }
void user_init(void) { uart_div_modify(0, UART_CLK_FREQ / 115200); os_delay_us(500); printf("SDK version : %s\n", system_get_sdk_version()); mainqueue = xQueueCreate(10, sizeof(my_event_t)); connectToAp(); //setap("test", 4); init_led(); PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5); PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO5_U); // disable pullodwn GPIO_REG_WRITE(GPIO_ENABLE_W1TS_ADDRESS,BIT5); GPIO_OUTPUT_SET(GPIO_ID_PIN(5), 1); char outbuffer[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; WS2812OutBuffer( outbuffer, 6 , 0); //Initialize the output. write_textwall_buffer(0, "BIER ", 5); xTaskCreate(simple_task, (signed char * )"simple_task", 256, &mainqueue, tskIDLE_PRIORITY, NULL); xTaskCreate(receive_udp, (signed char * )"test", 256, &mainqueue, tskIDLE_PRIORITY, NULL); timerHandle = xTimerCreate((signed char *) "Trigger", 50 / portTICK_RATE_MS, pdTRUE, NULL, timer_cb); if (timerHandle != NULL) { if (xTimerStart(timerHandle, 0) != pdPASS) { printf("%s: Unable to start Timer ...\n", __FUNCTION__); } } else { printf("%s: Unable to create Timer ...\n", __FUNCTION__); } }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { uart_div_modify(0, UART_CLK_FREQ / 115200); wifi_set_opmode(STATION_MODE); websocket_start(&test_mode); }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { uart_div_modify(0, UART_CLK_FREQ / 115200); os_printf("SDK version:%s\n", system_get_sdk_version()); uint32 num = 0; #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(); /*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 */ user_light_init(); user_webserver_init(SERVER_PORT); pwm_set_duty(10000, 0); pwm_start(); }
void ICACHE_FLASH_ATTR uart0_baud(int rate) { #ifdef UART_DBG os_printf("UART %d baud\n", rate); #endif uart_div_modify(UART0, UART_CLK_FREQ / rate); }
uint32_t set_baud_rate(uint32_t uart_no, uint32_t old_baud_rate, uint32_t new_baud_rate) { uint32_t uart_reg = READ_PERI_REG(UART_CLKDIV_REG(uart_no)); uint32_t uart_div = uart_reg & UART_CLKDIV_M; uint32_t master_freq = uart_div * old_baud_rate; uart_div_modify(uart_no, master_freq / new_baud_rate); return uart_div; }
bool miot_uart_dev_init(struct miot_uart_state *us) { struct miot_uart_config *cfg = us->cfg; if (!esp_uart_validate_config(cfg)) return false; ETS_INTR_DISABLE(ETS_UART_INUM); uart_div_modify(us->uart_no, UART_CLK_FREQ / cfg->baud_rate); if (us->uart_no == 0) { PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD); if (cfg->swap_rxcts_txrts) { SET_PERI_REG_MASK(PERIPHS_DPORT_BASEADDR + HOST_INF_SEL, PERI_IO_UART0_PIN_SWAP); } else { CLEAR_PERI_REG_MASK(PERIPHS_DPORT_BASEADDR + HOST_INF_SEL, PERI_IO_UART0_PIN_SWAP); } } else { PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO2_U); PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK); if (cfg->swap_rxcts_txrts) { SET_PERI_REG_MASK(PERIPHS_DPORT_BASEADDR + HOST_INF_SEL, PERI_IO_UART1_PIN_SWAP); } else { CLEAR_PERI_REG_MASK(PERIPHS_DPORT_BASEADDR + HOST_INF_SEL, PERI_IO_UART1_PIN_SWAP); } } unsigned int conf0 = 0b011100; /* 8-N-1 */ if (cfg->tx_fc_ena) { conf0 |= UART_TX_FLOW_EN; PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_U0CTS); } WRITE_PERI_REG(UART_CONF0(us->uart_no), conf0); unsigned int conf1 = cfg->rx_fifo_full_thresh; conf1 |= (cfg->tx_fifo_empty_thresh << 8); if (cfg->rx_fifo_alarm >= 0) { conf1 |= UART_RX_TOUT_EN | ((cfg->rx_fifo_alarm & 0x7f) << 24); } if (cfg->rx_fc_ena && cfg->rx_fifo_fc_thresh > 0) { /* UART_RX_FLOW_EN will be set in uart_start. */ conf1 |= ((cfg->rx_fifo_fc_thresh & 0x7f) << 16); PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_U0RTS); } WRITE_PERI_REG(UART_CONF1(us->uart_no), conf1); s_us[us->uart_no] = us; /* Start with TX and RX ints disabled. */ WRITE_PERI_REG(UART_INT_ENA(us->uart_no), UART_INFO_INTS); ETS_UART_INTR_ATTACH(esp_uart_isr, NULL); ETS_INTR_ENABLE(ETS_UART_INUM); return true; }
void user_init(void) { uart_div_modify(0, UART_CLK_FREQ / 115200); setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); xTaskCreate(mg_task, (const signed char *) "mongoose", MG_TASK_STACK_SIZE, NULL, MG_TASK_PRIORITY, &s_mg_task_handle); }
/****************************************************************************** * FunctionName : uart_config * Description : Internal used function * UART0 used for data TX/RX, RX buffer size is 0x100, interrupt enabled * UART1 just used for debug output * Parameters : uart_no, use UART0 or UART1 defined ahead * Returns : NONE *******************************************************************************/ static void ICACHE_FLASH_ATTR uart_config (uint8 uart_no) { UART_TypeDef *uart_p; if (uart_no == UART1) { uart_p = UART_1; IOMUX->gpio2_mux &= ~GPIO_MUX_FUNC_MASK; IOMUX->gpio2_mux |= GPIO2_FUNC_U1TXD; } else { uart_p = UART_0; /* rcv_buff size if 0x100 */ ets_isr_attach (5, uart0_rx_intr_handler, (void *)&UartDev.rcv_buff); IOMUX->gpio1_mux_bits.pullup = 0; IOMUX->gpio1_mux_u0_txd &= ~GPIO_MUX_FUNC_MASK; IOMUX->gpio1_mux_u0_txd |= GPIO1_FUNC_U0TXD; IOMUX->gpio15_mux_mtdo &= ~GPIO_MUX_FUNC_MASK; IOMUX->gpio15_mux_mtdo |= GPIO15_FUNC_U0RTS; } uart_div_modify (uart_no, UART_CLK_FREQ / (UartDev.baut_rate)); uart_p->conf0 = (UartDev.exist_parity | UartDev.parity | (UartDev.stop_bits << 4) //UART_STOP_BIT_NUM_S) | (UartDev.data_bits << 2)); //UART_BIT_NUM_S)); //clear rx and tx fifo,not ready uart_p->conf0 |= UART_CONF0_RXFIFO_RST | UART_CONF0_TXFIFO_RST; uart_p->conf0 &= ~(UART_CONF0_RXFIFO_RST | UART_CONF0_TXFIFO_RST); if (uart_no == UART0) { //set rx fifo trigger uart_p->conf1_bits.rx_fifo_full_trhd = 0x10; uart_p->conf1_bits.rx_flow_trhd = 0x10; uart_p->conf1_bits.rx_flow_en = 1; uart_p->conf1_bits.rx_tout_trhd = 0x02; uart_p->conf1_bits.rx_tout_en = 1; uart_p->int_ena |= UART_INT_ENA_RXFIFO_TOUT | UART_INT_ENA_FRM_ERR; } else { uart_p->conf1_bits.rx_fifo_full_trhd = UartDev.rcv_buff.TrigLvl; } //clear all interrupt uart_p->int_clr = UART_INT_CLR_MASK; //enable rx_interrupt uart_p->int_ena_bits.rx_fifo_full = 1; }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { /* * set uart baut ratio */ uart_div_modify(0, UART_CLK_FREQ / UART_BAUT_RATIO); uart_div_modify(1, UART_CLK_FREQ / UART_BAUT_RATIO); if (!esp_mesh_demo_init()) return; user_devicefind_init(); /* * enable mesh * after enable mesh, you should wait for the mesh_enable_cb to be triggered. */ espconn_mesh_enable(mesh_enable_cb, MESH_ONLINE); }
/* Init function */ void user_init() { system_update_cpu_freq(SYS_CPU_160MHZ); system_init_done_cb(sdk_init_done_cb); uart_div_modify(ESP_DEBUG_UART, UART_CLK_FREQ / 115200); esp_exception_handler_init(); gpio_init(); }
extern "C" void user_init(void) { system_timer_reinit(); uart_div_modify(UART_ID_0, UART_CLK_FREQ / 115200); cpp_core_initialize(); spiffs_mount(); System.initialize(); init(); // User code init }
/****************************************************************************** * FunctionName : uart_config * Description : Internal used function * UART0 used for data TX/RX, RX buffer size is 0x100, interrupt enabled * UART1 just used for debug output * Parameters : uart_no, use UART0 or UART1 defined ahead * Returns : NONE *******************************************************************************/ static void ICACHE_FLASH_ATTR uart_config(uint8 uart_no) { if (uart_no == UART1) { PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK); //PIN_PULLDWN_DIS(PERIPHS_IO_MUX_GPIO2_U); PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO2_U); } else { /* rcv_buff size is 0x100 */ ETS_UART_INTR_ATTACH(uart0_rx_intr_handler, &(UartDev.rcv_buff)); PIN_PULLUP_DIS (PERIPHS_IO_MUX_U0TXD_U); //PIN_PULLDWN_DIS(PERIPHS_IO_MUX_U0TXD_U); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD); PIN_PULLUP_DIS (PERIPHS_IO_MUX_U0RXD_U); //PIN_PULLDWN_DIS(PERIPHS_IO_MUX_U0RXD_U); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, 0); // FUNC_U0RXD==0 } uart_div_modify(uart_no, UART_CLK_FREQ / UartDev.baut_rate); if (uart_no == UART1) //UART 1 always 8 N 1 WRITE_PERI_REG(UART_CONF0(uart_no), CALC_UARTMODE(EIGHT_BITS, NONE_BITS, ONE_STOP_BIT)); else WRITE_PERI_REG(UART_CONF0(uart_no), CALC_UARTMODE(UartDev.data_bits, UartDev.parity, UartDev.stop_bits)); //clear rx and tx fifo,not ready SET_PERI_REG_MASK(UART_CONF0(uart_no), UART_RXFIFO_RST | UART_TXFIFO_RST); CLEAR_PERI_REG_MASK(UART_CONF0(uart_no), UART_RXFIFO_RST | UART_TXFIFO_RST); if (uart_no == UART0) { // Configure RX interrupt conditions as follows: trigger rx-full when there are 80 characters // in the buffer, trigger rx-timeout when the fifo is non-empty and nothing further has been // received for 4 character periods. // Set the hardware flow-control to trigger when the FIFO holds 100 characters, although // we don't really expect the signals to actually be wired up to anything. It doesn't hurt // to set the threshold here... // We do not enable framing error interrupts 'cause they tend to cause an interrupt avalanche // and instead just poll for them when we get a std RX interrupt. WRITE_PERI_REG(UART_CONF1(uart_no), ((80 & UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S) | ((100 & UART_RX_FLOW_THRHD) << UART_RX_FLOW_THRHD_S) | UART_RX_FLOW_EN | (4 & UART_RX_TOUT_THRHD) << UART_RX_TOUT_THRHD_S | UART_RX_TOUT_EN); SET_PERI_REG_MASK(UART_INT_ENA(uart_no), UART_RXFIFO_FULL_INT_ENA | UART_RXFIFO_TOUT_INT_ENA); } else { WRITE_PERI_REG(UART_CONF1(uart_no), ((UartDev.rcv_buff.TrigLvl & UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S)); } //clear all interrupt WRITE_PERI_REG(UART_INT_CLR(uart_no), 0xffff); }
void ICACHE_FLASH_ATTR user_init(void) { uart_div_modify(0, UART_CLK_FREQ / 115200); gpio_user_init(); printf("SDK version:%s\n", system_get_sdk_version()); //init_blinking_led(); network_init(); }
//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 arduino_init(void) { uart_div_modify(0, UART_CLK_FREQ / (115200)); init(); //disable uart0 debug, init wiring system: pins, timer1 initVariant(); cont_init(&g_cont); system_os_task(loop_task, LOOP_TASK_PRIORITY, g_loop_queue, LOOP_QUEUE_SIZE); system_init_done_cb(&init_done); }
/* * This is entry point for user code */ void ICACHE_FLASH_ATTR user_init(void) { uart_div_modify(UART0, UART_CLK_FREQ / (BIT_RATE_115200)); show_free_mem(0); wifi_softap_dhcps_stop(); show_free_mem(1); PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0); // GPIO 0 PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); // GPIO 2 xTaskCreate(jerry_task, "jerry", JERRY_STACK_SIZE, NULL, 2, NULL); }
//Init function void ICACHE_FLASH_ATTR user_init() { char ssid[32] = SSID; char password[64] = SSID_PASSWORD; struct station_config stationConf; //Set output debugger bandwidth uart_div_modify(0, UART_CLK_FREQ / 115200); //Set station mode wifi_set_opmode( 0x1 ); //Set ap settings os_memcpy(&stationConf.ssid, ssid, 32); os_memcpy(&stationConf.password, password, 64); if ( wifi_station_set_config(&stationConf) ) { os_printf("Wi-fi configured\n"); } else { os_printf("ERROR:Wi-fi NOT configured\n"); } struct espconn connection; ip_addr_t ipaddr; ipaddr.addr = 3105625166U; // hardcoded IP of golink.besaba.com int rtr_val; if ( (rtr_val = espconn_gethostbyname(&connection, HOSTNAME, &ipaddr, gethost_callback)) != ESPCONN_OK ) { if (rtr_val == ESPCONN_INPROGRESS) { os_printf("ERROR:espconn_gethostbyname INPROGRESS\n"); } else if (rtr_val == ESPCONN_ARG) { os_printf("ERROR:espconn_gethostbyname ARG\n"); } else { os_printf("ERROR:espconn_gethostbyname UNKNOWN ERROR\n"); } } //Start os task system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen); system_os_post(user_procTaskPrio, 0, 0 ); }
void ICACHE_FLASH_ATTR user_init(void) { uart_div_modify(0, UART_CLK_FREQ / BAUD); os_printf("Startup\r\n"); /*** Initialize subsystems ***/ psu_init(); ws2811dma_init(); wifi_init(); mxp_init(ws2811dma_put); psu_server_init(); /*** Use LED strip as status indicator ***/ wifi_set_event_handler_cb(onWifiEvent); status_indicate(STAT_NO_CONNECT); }
void uart_main_init(int baud_rate) { #ifndef RTOS_SDK system_os_task(rx_task, TASK_PRIORITY, rx_task_queue, RXTASK_QUEUE_LEN); #endif if (baud_rate != 0) { uart_div_modify(0, UART_CLK_FREQ / baud_rate); } #ifndef RTOS_SDK ETS_UART_INTR_ATTACH(rx_isr, 0); ETS_INTR_ENABLE(ETS_UART_INUM); #else _xt_isr_attach(ETS_UART_INUM, rx_isr, 0); _xt_isr_unmask(1 << ETS_UART_INUM); #endif }
extern "C" void user_init(void) { struct rst_info *rtc_info_ptr = system_get_rst_info(); memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo)); uart_div_modify(0, UART_CLK_FREQ / (115200)); init(); initVariant(); cont_init(&g_cont); system_os_task(loop_task, LOOP_TASK_PRIORITY, g_loop_queue, LOOP_QUEUE_SIZE); system_init_done_cb(&init_done); }
void stub_main() { uint32_t baud_rate = params[0]; uint32_t greeting = 0x4941484f; /* OHAI */ uint8_t last_cmd; /* This points at us right now, reset for next boot. */ ets_set_user_start(NULL); /* Selects SPI functions for flash pins. */ SelectSpiFunction(); if (baud_rate > 0) { ets_delay_us(1000); uart_div_modify(0, UART_CLKDIV_26MHZ(baud_rate)); } /* Give host time to get ready too. */ ets_delay_us(10000); SLIP_send(&greeting, 4); last_cmd = cmd_loop(); ets_delay_us(10000); if (last_cmd == CMD_BOOT_FW) { /* * Find the return address in our own stack and change it. * "flash_finish" it gets to the same point, except it doesn't need to * patch up its RA: it returns from UartDwnLdProc, then from f_400011ac, * then jumps to 0x4000108a, then checks strapping bits again (which will * not have changed), and then proceeds to 0x400010a8. */ volatile uint32_t *sp = &baud_rate; while (*sp != (uint32_t) 0x40001100) sp++; *sp = 0x400010a8; /* * The following dummy asm fragment acts as a barrier, to make sure function * epilogue, including return address loading, is added after our stack * patching. */ __asm volatile("nop.n"); return; /* To 0x400010a8 */ } else {
void uart_debug_init(unsigned periph, unsigned baud_rate) { if (periph == 0) { periph = PERIPHS_IO_MUX_GPIO2_U; } if (baud_rate == 0) { baud_rate = 115200; } PIN_FUNC_SELECT(periph, FUNC_U1TXD_BK); uart_div_modify(UART_DEBUG, UART_CLK_FREQ / baud_rate); /* Magic: set 8-N-1 mode */ WRITE_PERI_REG(UART_CONF_TX(UART_DEBUG), 0xC); #ifndef RTOS_TODO os_install_putc1((void *) uart_system_tx_char); #endif }
void UARTInit() { //Enable TxD pin PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD); //Set baud rate and other serial parameters to 115200,n,8,1 uart_div_modify(0, UART_CLK_FREQ/BIT_RATE_115200); WRITE_PERI_REG(UART_CONF0(0), (STICK_PARITY_DIS)|(ONE_STOP_BIT << UART_STOP_BIT_NUM_S)| \ (EIGHT_BITS << UART_BIT_NUM_S)); //Reset tx & rx fifo SET_PERI_REG_MASK(UART_CONF0(0), UART_RXFIFO_RST|UART_TXFIFO_RST); CLEAR_PERI_REG_MASK(UART_CONF0(0), UART_RXFIFO_RST|UART_TXFIFO_RST); //Clear pending interrupts WRITE_PERI_REG(UART_INT_CLR(0), 0xffff); //Install our own putchar handler os_install_putc1((void *)UARTPutChar); }