Driver for the Wifi+bluetooth integrated circuit on the pico.
PRs welcome! Please read most recent developments on this issue before contributing.
Compile and flash the development program to the currently connected Pico W by running:
tinygo flash -monitor -target=pico ./shelltest/.
After the program is done flashing it will enter shell-mode communications with the Pico W. One has several commands they can run from there on out.
To initialize the board type in the following shell command and press enter
$i0
A shell command is composed of 4 parts and serves the purpose of debugging:
$
: While in shell-mode the program waits for the$
character before parsing input.- The next character after the
$
is the "command" character. - After the "command" is the number argument, which may not have effect in some commands
- The Enter or newline.
All commands must have these 4 parts
To develop add a command under the TestShellmode
function (switch statement).
This command will probably contain a function or action with the CYW43439 you wish to test.
-
-
cyw43_driver/cyw43_bus_pio_spi.c
: Core driver for interfacing directly with the CYW43439. This is what this repo will target in the port. -
pico_cyw43_arch
: Architecture for integrating the CYW43 driver (for the wireless on Pico W) and lwIP (for TCP/IP stack) into the SDK. It is also necessary for accessing the on-board LED on Pico W.pico_cyw43_arch/include/pico/cyw43_arch.h
: Headers for the architecture driver. Has a very complete comment introducing the architecture library.
Examples:
- APA102 addressable LED strip.
- Here is the Go driver: well programmed and simple. Follows good practices like storing buffers in-struct as arrays (
buf
field) to avoid heap allocations and encouraging better CPU memory access patterns. - I could not find a high quality C or C++ driver, there seems to be a different driver for each microcontroller. Here's an ESP8266 driver for the APA102 which seemed reasonably well programmed.
- Here is the Go driver: well programmed and simple. Follows good practices like storing buffers in-struct as arrays (
- Wifinina SPI driver for ESP32 wifi with TCP/IP.
The CYW43439 driver will have minimal microcontroller side API code, though it does not hurt to read up a little bit on it.
It may be of interest to the reader to know a bit of how one ports microcontroller specific code from C to Go. This code is characterized by the heavy use of volatile memory registers and data structures that map peripheral functionality directly to these segments of volatile memory.
For the case of the RP2040 (the raspberry pi's pico microcontroller) one can find most of microcontroller specific code in the TinyGo machine
package- Look for filenames starting with machine_rp2040
. In the author's opinion one of the cleanest peripheral API's is the RP2040's I2C driver, which you may find in machine_rp2040_i2c.go
in said package.
The C counterparts are in the pico-sdk's rp2_common
directory. The I2C counterpart includes the header file with function signatures and type definitions... and more interestingly, the actual code under hardware_i2c/i2c.c
. Do note the port is almost direct. Some functions have been grouped differently and have slightly different signatures in the Go
version.
The PWM API is much more closely matched between the C and Go version, albeit much simpler.