本代码基于ESP-IDF 4.2 SDK编写,具体UART可参考官方例程
一、ESP32总共有3个串口,并且3个 串口管脚都是可以重映射的
1.串口收发代码编写
1.1加载串口相关的头文件、定义串口IO映射引脚、定义串口缓存等
/**
* This is an example which echos any data it receives on UART1 back to the sender,
* with hardware flow control turned off. It does not use UART driver event queue.
*
* - Port: UART1
* - Pin assignment: see defines below
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/uart.h"
#include "driver/gpio.h"
#include "cJSON.h"
#include "esp_log.h"
#include "sdkconfig.h"
#include "esp_system.h"
#