Commit graph

454 commits

Author SHA1 Message Date
Michael van Niekerk
f69e8459c9 RP2040: Fixes as per PR 2023-08-30 21:52:03 +02:00
Michael van Niekerk
891f1758bc RP2040: XOSC delay multiplier 2023-08-30 21:43:57 +02:00
Michael van Niekerk
ae174fd0e0 RP2040: XOSC delay multiplier 2023-08-30 21:42:27 +02:00
Dario Nieuwenhuis
5e613d9abb Sync all fmt.rs files. 2023-08-30 01:37:18 +02:00
Jesse Braham
1f63bf4153 Release embassy-time v0.1.3 2023-08-28 08:00:18 -07:00
Dániel Buga
a2c718f61c Bump executor crate version to 0.3.0 2023-08-23 20:34:37 +02:00
Dario Nieuwenhuis
b948e37769 rp/flash: change naming to blocking_*, new_blocking.
- Needed for consistency with other drivers.
- Having two `new()` functions sometimes resulted in 'multiple applicable methods' errors.
2023-08-18 13:21:21 +02:00
Dario Nieuwenhuis
f26dd54f63
Update embedded-hal to 1.0.0-rc.1 (#1783) 2023-08-16 00:40:56 +02:00
Dario Nieuwenhuis
46f671ae42 rp: fix async spi read sometimes hanging. 2023-08-15 22:47:58 +02:00
Dario Nieuwenhuis
5d5cd23715
Update to embedded-io 0.5 (#1752) 2023-08-07 13:43:09 +02:00
pennae
3c5f011245 rp: add generic dormant-sleep functionality
this is "generic" in that it doesn't require the user to set up anything
specific to go to dormant sleep, unlike the C sdk which requires clock
sources to be configured explicitly and doesn't much care about PLLs. we
will instead take a snapshot of the current clock configuration, switch
to a known clock source (very slow rosc, in this case), go to sleep, and
on wakeup undo everything we've done (ensuring stability of PLLs and
such).

tested locally, but adding tests to HIL seems infeasible. we'd need at
least another pico or extensive modifications to teleprobe since
dormant-sleep breaks SWD (except to rescue-dp), neither of which is
feasible at this point. if we *did* want to add tests we should check
for both rtc wakeups (with an external rtc clock source) and gpio wakeups.
2023-08-05 00:57:29 +02:00
pennae
9dfda46e0c rp: add dormant-wake functionality for Input
this temporarily takes ownership of pins because we need to clear edge
interrupts before waiting for them (otherwise we may wait indefinitely),
we want to clean up the dormant-wake bits after a wakeup, and doing
anything *else* with the input while we're waiting for a wakeup isn't
possible at all. doing it like this lets us not impose any cost on those
who don't use dormant wakes without entangling dormant waits too badly
with regular interrupt waits.
2023-08-03 19:22:47 +02:00
pennae
a6b8f3d994 rp: add single-channel dma from adc
with uniform treatment of adc inputs it's easy enough to add a new
sampling method. dma sampling only supports one channel at the moment,
though round-robin sampling would be a simple extension (probably a new
trait that's implemented for Channel and &[Channel]). continuous dma as
proposed in #1608 also isn't done here, we'd expect that to be a
compound dma::Channel that internally splits a buffer in half and
dispatches callbacks or something like that.
2023-08-02 17:04:32 +02:00
pennae
b166ed6b78 rp: generalize adc inputs from pins to channels
this lets us treat pins and the temperature sensor uniformly using the
same interface. uniformity in turn lets us add more adc features without
combinatorial explosion of methods and types needed to handle them all.
2023-08-01 18:31:28 +02:00
pennae
54d31c98fe rp: remove AdcChannel::channel
we're not using it, and actually using it is more trouble than it's
worth. remove the false assurance instead.
2023-08-01 18:31:28 +02:00
pennae
48eac0b146 rp: add AdcChannel trait
this is more general than AdcPin and can also cover the temperature
sensor.
2023-08-01 18:31:28 +02:00
Dario Nieuwenhuis
ef3b1f46a9
Merge pull request #1728 from pennae/rp-gpio-banks
rp: fix qspi gpio interrupts, make qspi gpio optional
2023-08-01 08:18:39 +00:00
pennae
f3ad0c6ade rp: fix qspi gpio interrupts
so far only bank0 interrupts were processed and configured, even if a
qspi pin was given. this is obviously not the right thing to do, so
let's rectify that. the fact that no problems have shown up so far does
suggest that most, if not all, applications don't use this functionality
at all.
2023-07-31 20:02:06 +02:00
Dario Nieuwenhuis
4da9743317
Merge pull request #1690 from Sizurka/rp-flash-ptr-fix
rp: Fix ROM cache ptr() returning the trampoline
2023-07-31 17:26:59 +00:00
pennae
dca1777a2f rp: make QSPI gpio support optional
this will be mostly not useful to anyone since flash is attached to
qspi, and using flash chips that don't use the *entire* qspi interface
will severly slow down the chip. the code overhead is minimal right now,
but if we also fix interrupt support on qspi pins this will
change (adding more code to potentially hot paths, using more memory for
wakers that are never used, and preventing the qspi gpio irq from being
used in software interrupts as RTIC applications may want to do).
2023-07-31 19:13:10 +02:00
pennae
2c6fcdbd3f rp: add gpio::Pin::io() for access to io banks 2023-07-31 18:36:37 +02:00
pennae
e6d4043279 rp: rename gpio::Pin::io to gpio::Pin::gpio
we'll need access to the pin io bank registers for an upcoming fix, and
having both `io` and `io_bank` or similar can get confusing quickly.
rename `io` to `gpio` to avoid this, and also match the type while there.
2023-07-31 18:28:31 +02:00
Derek Hageman
7ed9e29326 rp: add async flash
Implement an async flash mode using the XIP background best effort
read interface.  Only reads are actually async, write and erase remain
blocking.
2023-07-28 16:50:54 -06:00
pennae
cbc8871a0b rp: relocate programs implicitly during load
this removed the RelocatedProgram construction step from pio uses.
there's not all that much to be said for the extra step because the
origin can be set on the input program itself, and the remaining
information exposed by RelocatedProgram can be exposed from
LoadedProgram instead (even though it's already available on the pio_asm
programs, albeit perhaps less convenient). we do lose access to the
relocated instruction iterator, but we also cannot think of anything
this iterator would actually be useful for outside of program loading.
2023-07-28 19:33:02 +02:00
Dario Nieuwenhuis
036e6ae30c
Rename embassy-hal-common to embassy-hal-internal, document it's for internal use only. (#1700) 2023-07-28 13:23:22 +02:00
Dario Nieuwenhuis
0ced8400d0
Merge pull request #1674 from pennae/rp-stack-guards
Rp stack guards
2023-07-28 10:43:54 +00:00
Derek Hageman
a5f2152077 rp: Fix ROM cache ptr() returning the trampoline
Make sure that the ptr() function for ROM functions always returns
the actual ROM pointer.  This allows the use of flash I/O while the
function cache is enabled.
2023-07-26 06:50:43 -06:00
pennae
e9445ec72d rp: allow for MPU-based stack guards on core 0 as well
using these will require some linker script intervention. setting the
core0 stack needs linker intervention anyway (to provide _stack_start),
having it also provide _stack_end for the guard to use is not that much
of a stretch.
2023-07-21 18:51:35 +02:00
pennae
4d6b3c57b1 rp: fix multicore stack guard setup
the region field of the register is four bits wide followed by the valid
bit that causes the rnr update we rely on for the rasr write. 0x08 is
just a bit short to reach the valid bit, and since rp2040 has only 8
regions it (at best) doesn't do anything at all.
2023-07-20 16:08:59 +02:00
pennae
a3d4ae85b0 rp: disable adc hardware on Adc drop
the adc constantly pulls a small but significant amount of current while
the hardware is enabled. this can have quite an effect on sleeping
devices that also use the adc.
2023-07-20 15:48:59 +02:00
Alex Ferro
e4ad1aa542 Embassy-rp I2C: Fix 1664
Change embassy-rp i2c.rs impl of embedded_hal_async::i2c::I2c::transaction
to only do the call to setup() for address once per call to transactions.
Calling setup multiple times results in I2C transactions being skipped
on the bus, even across calls to transaction() or devices.
2023-07-16 19:59:35 -06:00
Ben Simms
460cdc9e0f
Check intrstatus before signalling suspended 2023-07-13 19:29:09 +01:00
Henrik Berg
ff2daaff67 RP: Watchdog scratch set/get with index: usize. 2023-07-12 16:41:35 +02:00
Henrik Berg
6d402fe393 RP: Don't reset RTC in Clock::init. Updated example. 2023-07-12 15:16:56 +02:00
Henrik Berg
466a391b52 RP: Add save/restore to Rtc. Example use. 2023-07-12 14:22:48 +02:00
Henrik Berg
a93714327e RP: Rename Rtc to match STM32 impl. Remove setting RTC in new(). 2023-07-12 14:22:48 +02:00
Henrik Berg
029b156563 RP: Add scratchN registers to watchdog. Add Clone and Debug to DateTime 2023-07-12 14:22:48 +02:00
Dario Nieuwenhuis
91c1d17f16 rp/gpio: fix is_set_high/is_set_low, expand tests. 2023-07-11 12:40:07 +02:00
Dario Nieuwenhuis
b0da6318f3
Merge pull request #1623 from pennae/rp-adc
rp/adc: rewrite the module
2023-07-07 15:52:48 +00:00
pennae
972cdd4265 rp/adc: rewrite the module
- don't require an irq binding for blocking-only adc
- abstract adc pins into an AnyPin like interface, erasing the actual
  peripheral type at runtime.
- add pull-up/pull-down functions for adc pins
- add a test (mostly a copy of the example, to be honest)
- configure adc pads according to datasheet
- report conversion errors (although they seem exceedingly rare?)
- drop embedded-hal interfaces. embedded-hal channels can do neither
  AnyPin nor pullup/pulldown without encoding both into the type
2023-07-07 17:46:35 +02:00
pennae
4b63829110 rp/pio: use bind_interrupts for irqs
closes #1338
2023-07-07 16:27:10 +02:00
Dario Nieuwenhuis
d137286981 Release embassy-time v0.1.2 2023-07-06 01:29:44 +02:00
Dario Nieuwenhuis
a101d9078d update embedded-hal crates. 2023-07-04 19:59:36 +02:00
Dario Nieuwenhuis
ce889900d6 Update rp-pac. 2023-06-29 02:09:51 +02:00
Dario Nieuwenhuis
a2d1e7f02c rp/usb: add TODO: implement VBUS detection. 2023-06-27 04:29:01 +02:00
Dietrich Beck
23c51a1874 disable pull-up and down resistors for rp adc blocking_read 2023-06-22 23:02:16 +02:00
Dario Nieuwenhuis
837ebe405f rp: update rp-pac. 2023-06-16 01:41:07 +02:00
Dario Nieuwenhuis
98c821ac39 Remove embassy-cortex-m crate, move stuff to embassy-hal-common. 2023-06-09 16:44:20 +02:00
Dario Nieuwenhuis
dc8e34420f Remove executor dep+reexports from HALs.
Closes #1547
2023-06-09 16:29:45 +02:00
Dario Nieuwenhuis
8c93805ab5 Add rt feature to HALs, cfg out interrupt handling when not set. 2023-06-08 18:57:03 +02:00