首页 > 其他分享 >微雪ESP32-S3-Zreo学习笔记之USB串口

微雪ESP32-S3-Zreo学习笔记之USB串口

时间:2024-01-24 19:59:05浏览次数:24  
标签:微雪 USB ESP esp 串口 include tusb LOGI

软件下载

  1. ESP32-S3-Zero没有板载USB转串口,无法实现自动下载。
  2. 下载软件时要按住Boot按键再上电,此时电脑会识别到一个USB模拟的COM口,可用于下载软件。

开发环境

编程环境是使用的esp-idf-4.4.2;

值得注意的是在此之前安装了esp-idf-5.0.2、esp-idf-5.1.2都不能正常使用,安装好后使用"idf.py set-target"没有效果,配置不了MCU型号,使用"idf.py menuconfig"会报错,打不开配置界面。出现这些错误的具体原因未知。

参考例程

参考例程是"tusb_console"

例程存储路径"ESP-IDF\Espressif\frameworks\esp-idf-v4.4.2\examples\peripherals\usb\tusb_console"

代码

/* USB Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/

// DESCRIPTION:
// This example contains minimal code to make ESP32-S2 based device
// recognizable by USB-host devices as a USB Serial Device printing output from
// the application.

#include <stdio.h>
#include <stdlib.h>
#include <sys/reent.h>
#include "esp_log.h"
#include "esp_vfs.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "tinyusb.h"
#include "tusb_cdc_acm.h"
#include "tusb_console.h"
#include "sdkconfig.h"
#include "esp_err.h"

static const char *TAG = "Main";
static const char *TaskTAG = "Task1";

static void hello_task(void *arg)
{
	static int cnt = 0;
	ESP_LOGI(TaskTAG, "Enter hello task.");
    while (1) {
		if(cnt % 2){
			ESP_LOGI(TaskTAG, "Even num.");
		}
		else{
			ESP_LOGI(TaskTAG, "Odd num.");
		}
        if(cnt >= 0xFFFFFFFF){
            cnt = 0;
        }
        else{
            cnt++;
        }
        vTaskDelay(2000 / portTICK_PERIOD_MS);
    }
}

void app_main(void)
{
    /* Setting TinyUSB up */
    tinyusb_config_t tusb_cfg = { 0 }; // the configuration uses default values
    ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg));
    tinyusb_config_cdcacm_t amc_cfg = { 0 }; // the configuration uses default values
    ESP_ERROR_CHECK(tusb_cdc_acm_init(&amc_cfg));
	esp_tusb_init_console(TINYUSB_CDC_ACM_0); // log to usb
	
	vTaskDelay(2000 / portTICK_PERIOD_MS);
	
	ESP_LOGI(TAG, "APP Version 1.00");
	ESP_LOGI(TAG, "USB initialization DONE");
	xTaskCreatePinnedToCore(hello_task, "stats", 4096, NULL, 3, NULL, tskNO_AFFINITY);/*启动hello_task*/
    while (1) {
        ESP_LOGI(TAG, "log -> USB");
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        fprintf(stdout, "example: print -> stdout\n");
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        fprintf(stderr, "example: print -> stderr\n");
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}

现象

  1. 软件下载完毕后,按下reset按键,电脑会重新识别USB模拟的串口,因此串口号可能会改变;

  2. 连接串口后,可以看到相应的打印信息;

标签:微雪,USB,ESP,esp,串口,include,tusb,LOGI
From: https://www.cnblogs.com/baiyh5329/p/17985723

相关文章

  • 工业RTU串口网关有哪些使用用途和使用场景
    工业RTU串口网关主要以串口形式实现对设备的链接和数据采集、传输,具有设备对接方便、设备对接数量多、系统整体稳定性高、部署快捷等优势,可以广泛应用于各种工业领域。本篇就为大家简单介绍一下工业串口网关的使用用途和使用场景: 1、系统兼容集成在工业物联网发展过程中,可能已......
  • xiaomir3g-openwrt-usbutils
    1、官方方式打开SSH;获取root权限;2、刷入openwrt官网包,在openwrtwiki;3、进入后台192.168.1.1,root,密码空;4、国内换镜像源,别用清华,中科大,阿里,腾讯的,他们的都不全,只用官方的镜像源;查找很简单,用设置源的地址,浏览器打开,记录镜像地址; 5、更新软件包;6、安装汉化包:luci-i18n-base......
  • C# SerialPort.Open() COM蓝牙串口阻塞问题
    这种问题一般是蓝牙串口的问题,即使设置了SerialPort.TimeOut也是没有用的,需要验证串口名称,跳过该串口SerialPort.Open()步骤这种有问题的蓝牙串口设备名称中会带有BTHENUM那么我们就要取到串口名称,C#提供的SerialPort类只能取到串口编号,所以我们需要借助WMI取串口名称privateb......
  • ROS串口通信报错:IO Exception (13): Permission denied, file /tmp/binarydeb/ros-noe
    ROS在串口通信时,当我们插入USB后,catkin_make之后,报错:IOException(13):Permissiondenied,file/tmp/binarydeb/ros-noetic-serial-1.2.1/src/impl/unix.cc,line151.[ERROR][1705845384.528602780]:Unabletoopenport这是usb权限不够的原因我们首先查看接口设备:l......
  • pico用usb adb连一段时间,貌似会退出并无法重连
    pico用usbadb连一段时间,貌似会退出并无法重连的问题可能有多种原因。以下是一些建议的解决方法:重启ADB服务:您可以尝试使用命令行adbkill-server停止ADB服务,然后使用adbstart-server重新启动ADB服务。最后,使用adbdevices查看设备连接状态。修改ADB端口:有时,端口被其他程序......
  • j3455黑群晖 安装ax88179的usb网卡
    参考的教程: https://vircloud.net/exp/dsm-ax88179.html#selection-183.3326-183.3339驱动下载: https://github.com/pocopico/rp-ext/tree/main/ax88179_178a/releases开启ssh.具体请自行搜索开启admin账号用户群组---用户账号---admin---右击编辑-----停用此用户账号......
  • Android setStatusBarDisable
    Android中的setStatusBarDisable方法详解在Android开发中,我们经常需要定制状态栏的显示效果,有时甚至需要禁用状态栏。Android提供了setStatusBarDisable方法来实现禁用状态栏的功能。什么是状态栏状态栏是Android设备上显示系统状态信息的区域,通常位于屏幕的顶部。状态栏显示包......
  • Ubuntu和windows连接串口设备方法
    Ubuntu和windows连接串口设备方法一、Ubuntu连接串口1.下载并安装minicom工具sudoapt-getinstallminicom2.串口板连接主机和电脑后执行命令进入串口界面sudominicom-b115200二、windows连接串口1.下载并安装putty工具https://www.putty.org2.打开PUTTY工具,进入对应界面,如......
  • WSL2 挂载 U 盘等 USB 设备
    微软WSL文档:https://learn.microsoft.com/zh-cn/archive/blogs/wsl/file-system-improvements-to-the-windows-subsystem-for-linux插入U盘等USB设备,然后将WSL2打开,比如Ubuntu20.04。建立挂载USB设备文件的文件夹:sudomkdir/mnt/e#将e换成Windows里显......
  • C#串口通讯实战:基础功能及高效数据传输
     概述:C#串口通讯示例展示了基本功能,包括打开/关闭串口、设置属性、发送和接收数据。通过SerialPort类实现,可根据需求扩展更复杂的串口通讯应用。最近有项目应用到串口通讯,网上找到一个C#写的调试工具,如下图: 需要的文末可下载。下面我再讲一下串口通讯的基本应用:在C#中......