- Links:
- A Pi Pico Oscilloscope
- RPScope
- ula
- scoppy
- logicanalyzer
- [Raspberry Pi Pico 200Khz Digital Oscilloscope](https://www.instructables.com Raspberry-Pi-Pico-200Khz-Digital-Oscilloscope/)
- picowi
- Picowi part 10: Web camera
- Scoppy
PIO相关
Links:
- Learn How To Access The Programmable I/O on the Raspberry Pi RP2040
- Learn how to Program and Debug Raspberry Pi Pico with SWD
- Pio-RP2040
- tinygo-org/pio
- RP2040 : PIO - case study
- Raspberry Pi pico PIO 初探
- Pico-PIO-USB
- Shift Registers – 74HC595 & 74HC165 with Arduino
- How 74HC595 Shift Register Works & Interface it with Arduino
- LCD parallel driver using Pico PIO
Simple example to demonstrate
1 | .program squarewave |
OpenOCD烧写调试
1 | ~$ ../configure --enable-cmsis-dap --enable-sysfsgpio --enable-imx_gpio --enable-bcm2835gpio --enable-xds110 --enable-ftdi --enable-stlink |
- 添加支持
Pyua PY25Q32H nor flash
的支持
1 | ~ openocd$ git diff |
- 烧写
1 | ~$ openocd -f interface/ftdi/ft232h-module-swd.cfg -f target/rp2040.cfg -c "program blink.elf verify reset exit" |
学习理解tinyusb+pico-sdk
编译工程结构
- TinyUSB is an open-source cross-platform USB Host/Device stack for embedded system, designed to be memory-safe with no dynamic allocation and thread-safe with all interrupt events are deferred then handled in the non-ISR task function.
1 | ~$ git clone https://github.com/hathach/tinyusb |
- 下面以
tinyusb/examples/device/cdc_msc
的工程为例。
1 | tinyusb/examples/device/cdc_msc$ tree |
- 分析
CMakeLists.txt
文件
1 | tinyusb/examples/device/cdc_msc$ cat -n CMakeLists.txt |
- 上面的
CMakeLists.txt
第4行引入其它的tinyusb/hw/bsp/family_support.cmake
文件,如下:
1 | tinyusb/hw/bsp$ cat family_support.cmake |
ta
TinyUSB
是一个嵌入式系统下开源跨平台的USB协议栈
,以RP2040为例,它的开发实现是要依赖于pico-sdk
的。编译工程
1 | ~ examples/device/video_capture$ mkdir build && cd build |
使用TFT_eSPI(ardion)
驱动ili9341 16bit
并口屏
安装rp2040 bsp
支持
- 安装第三方的arduino-pico库,让
Arduino IDE
可以支持rp2040
板子。 - 首先在
Arduino IDE -> File -> Preference -> Additional Boards Manager URLs:
添加下面的链接:
1 | https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json |
- 再打开
Board Manager
进行联网更新,搜索pico
并且安装Raspberry Pi Pico/RP2040
的包。
配置TFT_eSPI
打开已经预定义好的文件:
~/Arduino/libraries/TFT_eSPI/User_Setups/Setup107_RP2040_ILI9341_16bit_parallel.h
,把屏幕与RP2040
按照文件的线序进行连接。再打开
~/Arduino/libraries/TFT_eSPI/User_Setups/User_Setup_Select.h
,只打开上面这一个文件的注释。
1 | #include <User_Setups/Setup107_RP2040_ILI9341_16bit_parallel.h> |
- 选择打开一个
TFT_eSPI
内置的测试工程。这里使用的是官方的板子,就选择Tools -> Boards -> Rasperry Pi RP2040 Boards -> Rasperry Pi Pico
. 编译上传就可以看到结果,烧写过程中有可能需要手动复位BOOTSEL
按键。
简单逻辑分析仪示例
- Install Rust
1 | ~$ rustup target add thumbv6m-none-eabi |
- 连机编译与烧写运行
1 | ~$ git clone https://github.com/dotcypress/ula |
- Hold the BOOTSEL button while connecting your board to the computer, then run following command.
1 | ~$ cd ula |
PulseView
- Select Openbench Logic Sniffer & SUMP compatible protocol when connecting to μLA.
SigrokCli
- Scan for devices
1 | ~$ sigrok-cli -d ols:conn=/dev/tty.usbmodem_ula_1 --scan |
- Sample two 10 MHz square waves with 90° phase shift
1 | ~$ sigrok-cli -d ols:conn=/dev/tty.usbmodem_ula_1 |
LoRa通信
- Links:
USB协议栈
USB结构简介
- Links:
Descriptor Types
The most commonly used descriptors include:
- Device Descriptor
- Configuration Descriptor
- Interface Descriptor
- Endpoint Descriptor
- String Descriptor
Every USB device must have one Device Descriptor and at least one each of the Configuration, Interface, and Endpoint Descriptors.
Device Descriptor
- The Device Descriptor is the first descriptor read by the Host during enumeration. The purpose of the Device Descriptor is to let the Host know what specification of USB the device complies with and how many possible configurations are available on the device. Upon successful processing of the Device Descriptor, the Host will read all the Configuration Descriptors.
Configuration Descriptor
A device may have more than one configuration. Each device configuration is assigned a number. The Configuration Descriptor serves two purposes:
Informs the Host as to how many interfaces (i.e., virtual devices) are in the configuration. While it is common for a configuration to offer only one interface, Devices that appear like two or more products have more than one interface.
How much power the device will consume if this configuration is activated by the Host. If the device is capable of controlling its power consumption, it may offer more than one configuration. Each configuration will advertise how much power would be consumed if the configuration were to be activated.
Interface Descriptor
An Interface Descriptor describes the details of the function of the product. Key elements include the number of endpoints on the device and which USB device class is implemented by the endpoints. For example, if the device were a keyboard, the specified device class would be Human Interface Device (HID) and the number of endpoints would be two.
Endpoint Descriptor
- Each endpoint on a device has its own descriptor. The descriptor provides the endpoint address (i.e., endpoint number), the size of the endpoint, and the data transfer type used to access the endpoint.
- Endpoint 0 (EP0IN and EP0OUT) are reserved in every device for control purposes.
- A USB device can have up to 32 endpoints (16 OUT and 16 IN). Since EP0IN and EP0OUT are set aside as control endpoints, the maximum number of endpoints available to transmit application data is 30.
String Descriptor
- Strings Descriptors are optional human readable strings which the Host OS may display.
1 | ~$ lsusb -v -s 001:005 |
USB Transfer Types
Desc | Interrupt Transfers | Isochronous Transfers | Bulk Transfers |
---|---|---|---|
Benefits | High-reliability data transfers with a fixed response time | High bandwidth | High reliability with the potential for high bandwidth |
Drawback | Bandwidth may be limited (64 KBytes for Full-Speed USB) | No CRC hardware. If a CRC is needed it must be done in software. Long packets can limit the number of devices being enumerated. | Bandwidth may vary depending upon the number of interrupt endpoints enumerated and the activity of enumerated Isochronous endpoints. |
Typical Use | Mice, Keyboards, and Medical Devices | Audio/Video streaming, serial port emulation | Mass Storage and Printers |
Notes | Up to 90 percent of the frame can be allocated for Interrupt endpoints.The maximum length of the transfer depends upon the frame size used. | Up to 90 percent of the frame can be allocated for interrupt endpoints. When not in use the bandwidth used will be released. The maximum length of the transfer depends upon the frame size used. | Will take advantage of unused Isochronous bandwidth.The maximum length of the transfer depends upon the frame size used. |
Linux USB手抓包分析
1 | ~$ lsmod | grep "usbmon" |
- 这里测试需要监听的要目标设备,是
TinyUSB
的设备,在Bus 3, Device 90
,
1 | ~$ lsusb | grep "TinyUSB" |
- 打开
wireshark
, 选择usbmon3
开始抓包。如下图所示,这里抓到的是错误码的UVC
的包。
- 下面示例抓取一个正常的
UVC
的协议包。在Bus 3, Device 91
,
1 | ~$ lsusb | grep "EM-Camera" |
UVC相关
- Links:
CC1101
- Links: