PicoSPI library

I've created a barebones SPI library specifically for the Raspberry Pi Pico board.

This is to address some of the shortcomings of the current setup with both the official Arduino Pico release and Earle F Philhower's interim release - basically these two differ on their SPI support for the Pico, and the official Pico support currently doesn't allow access to the SPI1 unit on the Pico, only the SPI0 unit.

The two systems also differ on the default pins for the SPI0 unit (4..7 for official, 16..19 for Earle's).

The library is here: GitHub - MarkTillotson/PicoSPI: Lightweight SPI library for RasPi Pico board using the RP2040

Feel free to try it out and make reasonable suggestions - I just wanted an easy way to run both SPI units fairly flexibly as masters.

2 Likes

Sigh. Unless you've added significant new functionality, you should probably implement the API described by the SPI - Arduino Reference reference.
Mostly that would involve moving most of the functionality of your "configure" method into SPI.beginTransaction(SPI_SETTINGS(...))
(I say this with some trepidation, since I generally feel that Arduino has backed itself into some ridiculous corners trying to maintain backward compatibility...)

Platform to Platform compatibility is a pretty important issues. A significant number of the complaints about new boards are essentially "I used this simple sketch from my Uno that has no HW-specific code and it doesn't run on my PicoNano."

(Bypassing both the MBed and Pico SDK SPI APIs also makes me nervous. But that's a lot harder to evaluate.) (Doesn't the 2040 Nano Connect use SPI1 for its WLAN connections, which means ... I'm not sure what; but low-level access by other code might not be a good thing.)

The issue is that the Arduino SPI model is too limited and assumes a single hardware SPI module, the RP2040 has two independent SPI modules, and different pins map to different units. Neither existing library (official or Earle's) allows you to use both units, so until they get fixed I wanted to be able to use the chip!

earles had a update and in that i checked some stuff because it related to spi. its visible in the github repository files that were updated more recently. spi.h has default pin assignment for spi1 and earles has calling spi1 not just spi0. if your on 1.5.1 move to 1.7.0

the file you need to look at is in the arduino15 folder . for me its

C:\Users\UserName\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.7.0\variants\rpipico

Is there anyway to use this library or Earle Philhower's implementation to attach an SD card to SPI1? I have had no success implementing an SD card on SPI1 and an LCD screen on SPI0. I can get both running on SPI0 but I would like to use the dual cores, one to grab SD card data from SDI1 and the other to display the data on an LCD screen on SPI0, running simultaneously. (I have been using Earle's version of SD.h and Bodmer's TFT_eSPI.h). Thanks, Bill

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.