Cornell University ECE4760
Using LWIP with VGA
Access point and web server

Pi Pico RP2040

 

VGA driver and LWIP
Both the VGA driver written by Hunter Adams (and converted to 256 colors by Bruce) and the LWIP supplied as part of the C SDK use significant hardware to accelerate operations. The VGA driver uses 4 DMA channels and all 4 state machines in one PIO. The LWIP uses 2 DMA channels and two PIO state machines. LWIP defaults to PIO1 (see cyw43_bus_pio_spi.c), so the VGA must use PIO0. The LWIP uses the claim mechanism to grab DMA channels. This means that any unused channel may be grabbed. The VGA driver was modified to use the claim system so that it does not step on the channels used by LWIP. Once this small change was made, the two libraries played nicely together. At first, the ADC did not play nice with LWIP, but starting working when I got better at setting up LWIP. I am not sure why.

Access point and web server
The access point example code in the WIFI section of the picoW examples runs as-is, but I hacked it out of the examples build-structure to compile alone. The code brings up a stand-alone WIFI access point, with DHCP server, DNS server and web server. The supplied code serves one page, with one clickable link that toggles the picoW on-board LED. In the process of trying to figure out how ths all worked, I ended up adding a bunch of comments, generalized the query-string parser (query-string is the part of URL after the ? character), and adding ability to serve several pages of html. Since there is no file system, and no outside connection to the internet, the page request processing had to be quite simple, but supports run-time modifiable pages, text, html forms, hyperlinks, and javascript. The javascript, of course, runs on the browser.

As a first test, I wanted to see if a cell phone could act a a reasonable user interface to code running on the picoW. In this case the application code was just a video thread running on core1 which displayed the status of the server and browser variables. LWIP is running on core0. My Android phone connected to the picoW with no complaints. The code runs without a serial monitor or VGA attached, but obviously then you can only interact via browser.
Demo functionality:

Three screens are shown below relecting different views of the program state. First is a browser window running on my cellphone and after pressing the submit buttion. Notice that there is no internet connection and that the IP I chose for the server is 192.168.4.1. The page is ledtest. The data sent from the browser back to the server is after the ? character. The second image is the server serial console showing the LWIP boot messages, and, at the bottom, the command to set a variable to 220. The third image is the server-attached VGA screen showing the status of all the browser and console variables.

CODE, ZIP of project
Note that you will need to delete the build directory and specify a new one.


Copyright Cornell University July 30, 2023