ESP8266: Always call `uart_init` before `gpio_init`

I don’t remember if this is in the documentation, but having spent a few hours to figure things out, I consider this essential information that must be recorded here.

For example:

void ICACHE_FLASH_ATTR user_init(void)
{
    /*
     * Always call uart_init() before gpio_init()
     */
    uart_init(BIT_RATE_115200, BIT_RATE_115200);

    gpio_init();
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
    GPIO_DIS_OUTPUT(BUTTON_PIN);

    os_timer_disarm(&os_timer);
    os_timer_setfn(&os_timer, &main_on_timer, (void *)NULL);
    os_timer_arm(&os_timer, 50, 1);
}

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.