ESP8266 UART

来自Jack's Lab
(版本间的差异)
跳转到: 导航, 搜索
(SDK API)
(system_uart_swap ())
 
第113行: 第113行:
  
 
<pre>
 
<pre>
U0TXD --- PIN13 (MTDO)  ---> Output pin, NOT be pulled up externally in the initiallization stage
+
U0TXD --- PIN13 (MTDO, GPIO15)  ---> Output pin, NOT be pulled up externally in the initiallization stage
U0RXD --- PIN12 (MTCK)
+
U0RXD --- PIN12 (MTCK, GPIO13)
 
U0CTS --- PIN25
 
U0CTS --- PIN25
 
U0RTS --- PIN26  
 
U0RTS --- PIN26  

2017年9月20日 (三) 12:28的最后版本

目录

[编辑] 1 快速尝试

Noduino Falcon 开发板 或 nodemcu v1.0 开发板,USB 连上 PC


下载 SDK:

# clone the whole sdk
$ git clone git://github.com/icamgo/noduino-sdk.git noduino-sdk

# fetch the toolchain of esp8266
$ cd noduino-sdk
$ git submodule init
$ git submodule update
$ cd toolchain
$ ./gen.py
# generate the toolchain (you need Python 2.7)


插上开发板,编译上传一步完成:

$ cd ../example/hello
$ make flash
Uploading 28080 bytes from build/0x00000.bin to flash at 0x00000000
............................
Uploading 185236 bytes from build/0x40000.bin to flash at 0x00040000
...............................................................................................

上传完成后,11520 的波特率打开串口,就能看到定时输出的 "Hello World!" :

$ minicom -b 115200 -o -D /dev/ttyUSB0Welcome to minicom 2.6.1

Welcome to minicom 2.6.1

OPTIONS: I18n 

Compiled on Feb 11 2012, 18:12:55.
Port /dev/ttyUSB0
Press CTRL-A Z for help on special keys

Hello World!
Hello World!
Hello World!
......
......



[编辑] 2 硬件管脚

UART0
U0TXD --- PIN26 
U0RXD --- PIN25
U0CTS --- PIN12 (MTCK)
U0RTS --- PIN13 (MTDO)


UART1 -- Only ouput pin, used for printing of debug information
 U1TXD --- PIN14 (GPIO2)


Downloading: U0TXD+U0RXD or GPIO2+U0RXD

Communicating: UART0: U0TXD, U0RXD, MTDO(U0RTS), MTCK(U0CTS)

Debugging: UART1_TXD (GPIO2) can be used to print debugging information.


By default, UART0 will output some printed information when the device is powered on and is booting up. If this issue exerts influence on some specific applications, users can exchange the inner pins of UART when initializing, that is to say, exchange U0TXD, U0RXD with U0RTS, U0CTS



[编辑] 3 SDK API

[编辑] 3.1 uart_init ()

 void uart_init(UartBautRate uart0_br, UartBautRate uart1_br);

例如:

uart_init(115200, 115200);



[编辑] 3.2 uart0_sendStr ()

 void uart0_sendStr(const char *str);

例如:

uart0_sendStr("Pack lan packet error!\r\n");



[编辑] 3.3 system_uart_swap ()

After calling void system_uart_swap ():

U0TXD --- PIN13 (MTDO, GPIO15)   ---> Output pin, NOT be pulled up externally in the initiallization stage
U0RXD --- PIN12 (MTCK, GPIO13)
U0CTS --- PIN25
U0RTS --- PIN26 























个人工具
名字空间

变换
操作
导航
工具箱