home..

Week 03 - Embedded Programming

group page // repo source files // objectives

Contents

hero >

meta >

this week, we worked on programming an embedded something to implement an input and output.

earlier in the summer, I found an interesting sketch for the xiao rp2040, the circle.ino sketch for mouse emulation.

since we just came out of computer-controlled cutting week, I thought it might be interesting to treat the mouse as a toolend and pipe an svg to the movement of the mouse.

to demonstrate this idea, I received some assistance from chatgpt in writing a script that parses an .svg and outputs lines of code leveraging functions from mouse.h, taking the following form:

Mouse.move(x, y, 0);

the results were interesting:

programming the xiao rp2040 >

I referenced the excellent Adrian Torres’ xiao rp2040 programming tutorial and took the following steps:

datasheet >

backing up a bit, the rp2040 is a neat little chip.

a quick summary of some of its features, taken directly from its 1.2 summary section:

RP2040 is a low-cost, high-performance microcontroller device with flexible digital interfaces. Key features:

of course, this is for the rp2040 chip itself, and not specifically the xiao rp2040, which breaks out a limited selection of its pins.

something neat about this chip: it has a USB PHY interface and can function as either a Host or Device.

most run-of-the-mill microcontrollers didn’t have this feature available to them directly in the package (looking at the atmega and attiny families, and even some older esp32s); usually supplemented by a separate USB to serial interface chip from FTDI or the popular CH340 family, commonly found on Arduino clones and sourceable from asian suppliers. However, this may have changed with time.

the SAMD21 also has a physical USB interface, and I believe the ESP32-c3 has a physical USB interface as well.

In addition, there is a distinction between a controller being able to serve as a USB Host vs a USB Device.

an interesting artifact of this capability is present when flashing the Xiao RP2040; briefly, a window will open appearing to display the contents of the microcontrollers flash memory (like a normal thumb drive), before disappearing as if the thumb drive had been removed.

according to the documentation, (in section 2.8.4.1. The RPI-RP2 Drive), any type of file can be written to the RP2040, but will only be stored if its a valid UF2 file (which writes data to RAM or Flash).

lessons >

© 2023 Alan Han   •  Powered by Soopr   •  Theme  Moonwalk