Commit graph

43 commits

Author SHA1 Message Date
Earle F. Philhower, III
227d71ed18
Fix RP2350B SPI RX pin list (#2931)
Fixes #2930
2025-04-29 16:29:45 -07:00
Earle F. Philhower, III
e05dd50d62
Convert to SDK RP2350A/B determination (#2898)
* Convert to SDK RP2350A/B determination

Fixes #2878

The SDK uses `defined(PICO_RP2350) && !PICO_RP2350A` to indicate an RP2350B
chip, not the define PICO_RP2350B.

Match the SDK's usage by converting from `defined(PICO_RP2350B)` to
`defined(PICO_RP2350) && !PICO_RP2350A` and update the chip variants
accordingly.

* Need to explicitly override PICO_RP2350A for all

The *SDK*'s board definition file hardcodes a PICO_RP2350A value for
all boards, but we use the same board file for both A and B variants.
Override the SDK board definition in the variant definition file.

* Generic RP2350 needs 2-stage PICO_RP2350A setting

Also ensure SDK board definition included before pins_arduino.h for
clearing up redefinition errors.

* Factor out undef PICO_RP2350A

* Update Arduino.h
2025-04-08 16:02:54 -07:00
Earle F. Philhower, III
aabbba67ce
Add some Doxygen documentation to core and libraries (#2780) 2025-03-18 17:00:44 -07:00
46a58fb4b5
Early out of (un)maskInterrupts() if no GPIO interrupts need to be masked (#2831)
My application is designed to generate HSTX data on core0 in interrupts,
but also uses hardware SPI for SD card access.

It turns out that the amount of time spent in maskInterrupts/
unmaskInterrupts, even with an empty _usingIRQs, is too long.

Add a quick check and avoid touching the interrupt disable flag if
there's not actually any GPIO interrupt to (un)mask.
2025-02-28 12:44:47 -08:00
Earle F. Philhower, III
8c3170596f
Deduplicate SPI and SoftwareSPI routines (#2779) 2025-01-28 12:47:13 -08:00
Earle F. Philhower, III
5f6e4aff5c
Allow LWIP Ethernet HW IRQs > 32 (#2464)
Allow RP2350B boards to use GPIOs 31+ for the Ethernet HW IRQ line.
Also update SPI debug output with the new registers.
2024-09-16 12:35:46 -07:00
Earle F. Philhower, III
4d1d1d2304
Fix PICO_RP2350B define check for other peripherals (#2463)
Fixes #2461
2024-09-16 11:16:08 -07:00
Earle F. Philhower, III
76811d3c66
Add RP2350B generic/Pimoroni PGA2350 support (#2433)
* Add support for the extra 16 GPIO pins in the menus and core.
* Clean up Generic RP2350 PSRAM ("none" is valid) and flash (other than 16MB) options.
* Add extra GPIO<->peripheral connections
* Add Pimoroni PGA2350 RP2350B-based board
* Pins 32-47 can be used for PIOPrograms
* Avoid hang when PSRAM fails to initialize
* Move libpico to an RP2350B board for SDK (otherwise the SDK drops all GPIOHI support)
2024-09-11 18:55:28 -07:00
Earle F. Philhower, III
f45db86cc2
Migrate to 2.0.0 SDK (#2336)
* Update to 2.0.0 SDK
* Board type needs to be set before earliest SDK setup
* Platform includes update
* Boot2 files
* Simple compilation issues
* Build and link
* PIO rebuild with version
* Newlib wrapper update
* Force inclusion of runtime_init_* fcns
The linker was dropping all references to the library's included
runtime_init_xxx functions and hence things like the IRQ vector
table and mutexes and alarms weren't properly set up leading to
instant crashes on start up..

Explicitly call out one function from the object file stored in
the .A to force the inclusion of all the functions.  May be a better
way, heppy to hear any ideas.
* Fix SPI GPIO calls
* Fix Ethernet GPIO
* Remove SDK warnings
Remove the skipped error messages once the following PR merged:
https://github.com/raspberrypi/pico-sdk/pull/1786
* BTStack moved SBC encode/decode paths
* Platform.IO fixes
* BT No longer has special absolute mouse
* Rebuild and update OTA
* Rebuild BearSSL, too
* Update liker file to latest SDK
* Clean up libpicocmake
* Clean up LWIP/BT library names
2024-08-17 10:39:13 -07:00
Earle F. Philhower, III
e6c7ee7813
Add asynchronous SPI transactions (#2168)
Fixes #1192

Uses DMA operations to avoid the need to bit-bang or busy wait for SPI
operations that might be very slow. Optional, adds new API calls to enable.
Simple example included.
2024-05-21 14:08:36 -07:00
Earle F. Philhower, III
f33df254f1
Add SPI::setMOSI/setMISO, better match pin names (#2166) 2024-05-20 14:43:55 -07:00
Earle F. Philhower, III
c64a4a58d7
Fix initial SPI startup (#1970)
Clocks were not being set at all after #1934.  Ensure they are by initting
to an impossible 0hz clock on creation and ::end

Fixes #1969
2024-01-28 16:21:48 -08:00
Nerradia
02c272b091
Skip SPI re-init if clock frequency doesn't change (#1934) 2024-01-28 10:27:12 -08:00
Earle F. Philhower, III
c3a3526aad
Fix SPI 16-bit transfers (#1882)
Fixes #1879
Fixes #1874
2023-12-04 17:30:43 -08:00
Earle F. Philhower, III
280fc43731
Fix SPI debug print warning (#1881) 2023-12-04 12:48:49 -08:00
Earle F. Philhower, III
6a878cdee8
Only create SPI/Wire instances if variant defined (#1842)
Fixes #1841
2023-11-24 09:56:13 -08:00
Earle F. Philhower, III
5678bb9904
Don't break transfer16 into 2 8-bit CS periods (#1764)
With HW chip select enabled, transfer16's 2 individual byte transfers will
actualy deassert CS for a brief instant between bytes.  Avoid this by doing
a single multi-byte (2) tranfer of 16b.
2023-10-11 08:40:17 -07:00
Earle F. Philhower, III
52d50da56f
Avoid calling spi_set_format during SPI transfers (#1762)
Avoid potential interaction with Pico SDK 1.5.1 update that causes hiccups in
SPI transmissions.  SPI.transfer16 to use 8-bit transfers.

Fixes #1760
2023-10-11 08:22:01 -07:00
Earle F. Philhower, III
f60b7831c8
Add SPISlave class (#1717)
Allows the Pico to behave as an SPI slave and allows apps to respond
with appropriate data through callbacks.

Fixes #1680
2023-09-17 15:23:03 -07:00
Earle F. Philhower, III
c48cdeeea0
Protect SPI transaction start/end from race conditions (#1715)
It would be possible for an IRQ-driven SPI user to fire
while the main app's SPI.beginTransaction was in process.
This would result in incorrect state for the main app since
the IRQ may overwrite some settings that the app already
set.

Disable all IRQs around the begin and end processes to avoid
the possibility.
2023-09-16 13:59:37 -07:00
Earle F. Philhower, III
0be7c98dff
Support IRQ disabled SPI transactions (#1714)
Fixes #1147

When SPI.beginTransaction() is called, disable all GPIO IRQs that were
registered using SPI.usingInterrupt().  On SPI.endTransaction(), restore
all the IRQs to their prior state.
2023-09-16 13:31:14 -07:00
Earle F. Philhower, III
456b474a48
Allow re-setting identical pins without panic() (#1655)
Setting a pin to the current value is a no-op, not fatal.

Fixes #1652
2023-08-21 08:52:49 -07:00
LinusHeu
ca4637d14d
SPI debugging: tiny fix & log actual baudrate (#1641) 2023-08-10 07:39:36 -07:00
Carter Nelson
ba413bb7ad
Remove extra SPI byte flip (#1202)
Fixes #1201
2023-02-17 12:42:31 -08:00
Vishnu Mohanan
8a1e03739a
Fix SPI transfer16 return value (#1148)
The SPI transfer16() function returned wrongly oriented bytes. Replaced reverseByte() with reverse16Bit().

Fixes #1146
2023-01-31 08:09:53 -08:00
Earle F. Philhower, III
444bb24464
Remove debug printout warnings (#1091)
Exposed by #1090, remove ugly printf format warnings while in debug mode
2023-01-02 10:51:04 -08:00
Earle F. Philhower, III
e2b04e7405
Minor tweak, NULL=>nullptr (#844) 2022-09-07 14:41:04 -07:00
Earle F. Philhower, III
4d2f64a12b
Add bidirectional bulk SPI transfer, update SdFAT (#819)
Should speed up SD transfers significantly (2.5x+).

See #801
2022-08-31 07:42:34 -07:00
Earle F. Philhower, III
10b869ef30
Fix XIAO RP2040, allow swapping HW units 0/1 (#606)
Add plumbing to allow `Wire`, `Serial1`, `SPI1` to map to the 2nd
hardware unit for devices where the PCB layout only brings out the
2nd port.

Fix the Seeedstudio XAIO pins

Fixes #594
2022-06-04 21:37:28 -07:00
Earle F. Philhower, III
f46d7cc84f
Speed up SPI by not reinitting if the paramters are the same as before (#394)
Leave the SPI port initted after a transaction, and when a new one comes in
check if it is the same settings we're already running.  If so, do nothing.
If not, deinit and reinit.  In general the settings will be identical, so
this will speed things up massively.

Fixes #392
2021-12-27 12:25:12 -08:00
Earle F. Philhower, III
fd685aac82
PANIC on attempting an invalid setXXX pin (#182)
Fixes #169

Trying to change pinout while running, or to an illegal configuration,
will now immediately panic() with an error message.  Such an attempt
is a pretty big problem since pinouts are hardware related/static.

Prior code would fail silently and return false, but nobody checked
the setXXX return values, anyway.
2021-05-29 10:50:13 -07:00
Earle F. Philhower, III
1fd0b0404d
Add TinyUSB include to all libs (#180)
Fixes #167

For Serial when selecting TinyUSB.  Can't include in the core because Arduino IDE
will not link in libraries called from the core.  Instead, add the header to all
the standard libraries in the hope it will still catch some user cases where they
use these libraries.

See https://github.com/earlephilhower/arduino-pico/issues/167#issuecomment-848622174
2021-05-28 19:23:19 -07:00
Limor "Ladyada" Fried
860b43b342
Two board variant definitions and a high speed SPI transfer function (#172) 2021-05-26 18:09:49 -07:00
Earle F. Philhower, III
8016a932f3
Add astyle format, boards.txt, and package check (#166)
Miscellaneous CI checks for code style, boards.txt update, and that all
referenced packages are available.
2021-05-24 15:01:03 -07:00
Earle F. Philhower, III
83a32f1ba3
Add compilation to CI (#155)
Stolen from ESP8266, modified to run basic sanity compiles on the core.

Fix warnings identified by the new checks.
2021-05-22 02:58:57 -07:00
Earle F. Philhower, III
6e51516d6c
Set default pins for peripherals per datasheet (#103)
Using the official Raspberry Pi Pico datasheet and the Adafruit Feather
RP2040 schematic, set the default pins for peripherals to match.

Fixes #92
2021-04-16 10:23:43 -07:00
Earle F. Philhower, III
b463825374 Rationalize pin selection using readable template
Use a constexpr template to calculate the valid pins for different IO
hardware.  This lets us have an easily readable list of pin numbers that
we can adjust/check.
2021-03-25 17:54:46 -07:00
Earle F. Philhower, III
ba0777e557 Add SPI debug dumps 2021-03-17 17:35:41 -07:00
Earle F. Philhower, III
c0a606510c Clean up SPI library info 2021-03-16 22:11:16 -07:00
Earle F. Philhower, III
4ea383c0d7 Clean up SPI API, pin selection logic 2021-03-16 22:07:06 -07:00
Earle F. Philhower, III
ca7a219ee9 Clean up SPI library, add info 2021-03-16 21:44:17 -07:00
Earle F. Philhower, III
b3dad2ba62 Cleanup, add licenses to all files 2021-03-05 22:09:05 -08:00
Earle F. Philhower, III
93d194b0ac Add hardware SPI support
SPI = spi0, SPI1 = spi1
2021-03-05 21:44:40 -08:00