Repository navigation
Pico 2 W: import mcu (GPIO, ADC, PWM, UART, I2C, SPI, interrupts) - #75
Merged
Merged
Conversation
ports/rp2350/src/mg_hal.c gives the Pico 2 W everything in lib/mcu.goose the RP2350 has: GPIO on the header's pins, the ADC with captures the ADC paces itself (DMA, up to 500 kHz), PWM on the 8 slices, UART0/1, I2C0/1, SPI0/1 (MISO = MOSI through the controller's loopback), pin edges and timers as events, the chip's temperature and its hardware RNG. No DAC or CAN on the chip: those calls return their "none" values. The locking, the waits for interrupts and the event queue follow mg_h7.c. Checked on the board with no wiring (tests/stress/pico_hal.goose, every check passes), and the conformance samples still pass 22 of 22. Found there: erratum E9 held a pulled-down pin high after a pull-up (the input buffer now goes off for 20 us when a pin becomes pulled down); a 96-cycle ADC divider skipped every other start (the fastest rate now runs back to back); the temperature sensor read 3 C high just after it was switched on. The examples choose Pico pins, CI builds every non-WiFi example for the Pico, test_mcu covers its HAL, and the docs get a Pico 2 W column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
import mcu;on the Raspberry Pi Pico 2 W: GPIO, ADC, PWM, UART, I2C, SPI, pin and timer interrupts, the chip's temperature and hardware random numbers, inports/rp2350/src/mg_hal.c. The RP2350 has no DAC or CAN, so those calls return their "none" values, as the S3's DAC calls do. WiFi, and the LED on the WiFi chip, are still to come.On the board
A check program that needs no wiring ran on the Pico, with every check passing:
The examples ran on the board too:
interrupts,pwm(duty 10–90% measured exact),analog,serial(SPI reads back, I2C scan) andblink. The 22 conformance samples still match the PC.Found on the board
pin_input(pin, PULL_DOWN)now turns the pad's input buffer off for 20 µs, so the pull-down brings the pin low first. The docs give the datasheet's fix for a pin that something drives and then lets go: an external pull-down of 8.2 kΩ or less.Differences from the other boards (in the docs)
serial.gooseuses GPIO0 → GPIO1 there and says to connect them.i2c_probereads a byte, because the controller can't send an address alone.Elsewhere
test_mcu: now checks that the Pico defines everyextern fninlib/mcu.goose.tests/stress/pico_hal.goose: the wire-free check program, to run again on a board.Not checked
🤖 Generated with Claude Code