{"id":1430,"date":"2021-08-15T00:29:50","date_gmt":"2021-08-14T23:29:50","guid":{"rendered":"https:\/\/coding.moris.org\/?p=1430"},"modified":"2025-11-04T14:27:21","modified_gmt":"2025-11-04T14:27:21","slug":"esp8266-always-call-uart_init-before-gpio_init","status":"publish","type":"post","link":"https:\/\/priscimon.net\/coding\/2021\/08\/15\/esp8266-always-call-uart_init-before-gpio_init\/","title":{"rendered":"ESP8266: Always call `uart_init` before `gpio_init`"},"content":{"rendered":"\n<p>After spending a few hours to uncover this requirement, I think it is important to document it here.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void ICACHE_FLASH_ATTR user_init(void)\n{\n    \/*\n     * Always call uart_init() before gpio_init()\n     *\/\n    uart_init(BIT_RATE_115200, BIT_RATE_115200);\n\n    gpio_init();\n    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);\n    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);\n    GPIO_DIS_OUTPUT(BUTTON_PIN);\n\n    os_timer_disarm(&amp;os_timer);\n    os_timer_setfn(&amp;os_timer, &amp;main_on_timer, (void *)NULL);\n    os_timer_arm(&amp;os_timer, 50, 1);\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>After spending a few hours to uncover this requirement, I think it is important to document it here. For example:<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1430","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3I4g9-n4","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/1430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/comments?post=1430"}],"version-history":[{"count":6,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/1430\/revisions"}],"predecessor-version":[{"id":2008,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/1430\/revisions\/2008"}],"wp:attachment":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/media?parent=1430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/categories?post=1430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/tags?post=1430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}