﻿{"id":986,"date":"2015-04-25T21:16:02","date_gmt":"2015-04-25T13:16:02","guid":{"rendered":"http:\/\/www.tansoo.cn\/?p=986"},"modified":"2015-05-08T22:08:40","modified_gmt":"2015-05-08T14:08:40","slug":"esp8266%e7%ae%80%e5%8d%95%e7%9a%84%e4%b8%b2%e5%8f%a3%e5%ba%94%e7%94%a8","status":"publish","type":"post","link":"http:\/\/www.tansoo.cn\/?p=986","title":{"rendered":"ESP8266\u7b80\u5355\u7684\u4e32\u53e3\u5e94\u7528"},"content":{"rendered":"<p>ESP8266\u5171\u6709\u4e24\u7ec4UART\u63a5\u2f1d\uff0c\u5206\u522b\u4e3a\uff1a<br \/>\nUART0:<br \/>\nU0TXD: pin26(U0TXD)<br \/>\nU0RXD: pin25(U0RXD)<br \/>\nU0CTS: pin12(MTCK)<br \/>\nU0RTS: pin13(MTDO)<br \/>\nUART1:<br \/>\nU1TXD: pin14(GPIO2)<\/p>\n<p>UART0\u4f5c\u4e3a\u6570\u636e\u901a\u4fe1\u63a5\u2f1d\u53e3\uff0cUART1\u4f5c\u4e3adebug\u4fe1\u606f\u7684\u6253\u5370\u3002\u4e0d\u8fc7\u5728\u6700\u65b0\u53d1\u5e03\u7684SDK1.0.1\u4e2d\uff0cdebug\u4fe1\u606f\u7684\u9ed8\u8ba4\u6253\u5370\u4e5f\u6539\u5230\u901a\u8fc7UART0\u63a5\u53e3\u4e86\uff0c\u53ef\u4ee5\u76f4\u63a5\u5229\u7528os_printf()\u8fdb\u884c\u4fe1\u606f\u8f93\u51fa\u3002\u5f53\u4f60\u60f3\u901a\u8fc7UART1\u8f93\u51fadebug\u4fe1\u606f\u65f6\uff0c\u901a\u8fc7\u4ee5\u4e0b\u63a5\u2f1d\u53ef\u4ee5\u8bbe\u7f6e\u4eceuart0\u6216\u8005uart1\u53e3\u8f93\u51fa\u6253\u5370\u3002void UART_SetPrintPort(uint8 uart_no);<!--more--><\/p>\n<p>\u7531\u4e8eESP8266\u7684\u5f00\u53d1\u73af\u5883\u6ca1\u6709\u5728\u7ebf\u8c03\u8bd5\u529f\u80fd\uff0c\u6240\u4ee5\u5229\u7528os_printf()\u8fdb\u884c\u4fe1\u606f\u8f93\u51fa\u5728\u7a0b\u5e8f\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\u5c24\u4e3a\u91cd\u8981\u3002<\/p>\n<pre class=\"lang:c decode:true \">\/*\r\n\t\u4e32\u53e3\u53d1\u9001\u4e3e\u4f8b\r\n\twww.tansoo.cn\r\n*\/\r\n\r\n#include &lt;ets_sys.h&gt;\r\n#include &lt;osapi.h&gt;\r\n#include &lt;os_type.h&gt;\r\n#include &lt;gpio.h&gt;\r\n#include \"driver\/uart.h\"\r\n\r\n\/\/\u5b9a\u4e49\u4e00\u4e2a\u65f6\u95f4\u5b9a\u65f6\u5668\u53d8\u91cfhello_timer\r\nLOCAL os_timer_t hello_timer;\r\n\r\nLOCAL void ICACHE_FLASH_ATTR hello_cb(void *arg)\r\n{\r\n\tos_printf(\"Hello World!\\r\\n\");\r\n}\r\n\r\nvoid user_init(void)\r\n{\r\n\t\/\/ \u8bbe\u7f6e UART0\u4e0eUART1\u7684\u901a\u8baf\u901f\u7387\r\n\tuart_init(BIT_RATE_115200, BIT_RATE_115200);\r\n\r\n\t\/\/UART_SetPrintPort(UART1);  \/\/ SDK V1.0.1 \u6709\u6548\uff1b\r\n\r\n\t\/\/ \u53d6\u6d88\uff08\u505c\u6b62\uff09\u5b9a\u65f6\u5668hello_timer\r\n\tos_timer_disarm(&amp;hello_timer);\r\n\r\n\t\/\/ \u5c06\u65f6\u95f4\u5b9a\u65f6\u5668\u53d8\u91cfhello_timer\u5173\u8054\u5230\u4e00\u4e2a\u51fd\u6570hello_cb\uff08\uff09\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f1a\u5728\u5230\u8fbe\u5b9a\u65f6\u65f6\u95f4\u65f6\u6267\u884c\u4e00\u6b21\uff0c\r\n\tos_timer_setfn(&amp;hello_timer, (os_timer_func_t *)hello_cb, (void *)0);\r\n\r\n\t\/\/ \u8bbe\u7f6e\u65f6\u95f4\u5b9a\u65f6\u5668\u53d8\u91cfhello_timer\u7684\u65f6\u95f4\u5468\u671f\u4e3a3\u79d2\u948f\uff0c\u7b2c\u4e09\u4e2a\u53c2\u6570\u4e3a0\u65f6\uff0chello_cb\uff08\uff09\u53ea\u4f1a\u6267\u884c\u4e00\u6b21\uff0c\u5f53\u4e3a1\u65f6\uff0chello_cb\uff08\uff09\u4f1a\u5faa\u73af\u6267\u884c\u3002\r\n\tos_timer_arm(&amp;hello_timer, 3000, 1);\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ESP8266\u5171\u6709\u4e24\u7ec4UART\u63a5\u2f1d\uff0c\u5206\u522b\u4e3a\uff1a UART0: U0TXD: pin26(U0TXD) U0RXD [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[56,57],"class_list":["post-986","post","type-post","status-publish","format-standard","hentry","category-program","tag-esp8266","tag-uart"],"_links":{"self":[{"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts\/986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=986"}],"version-history":[{"count":0,"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=\/wp\/v2\/posts\/986\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=986"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tansoo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}