* Use rp2040-hal in all example (possibly through their bsp)
Some of the examples were using the cortex_m_rt::entry method which
misses the device specific spinlock re-initialisation.
This commits makes the usage more consistent by using rp2040_hal exported
macro as the only `entry` method used across examples.
* Add struct VectorTable to represent an interrupt vector table
* Add member function to VectorTable to initialise based on the current Interrupt Vector Table from VTOR
* Add member function to VectorTable to register an extern "C" function to call on interrupt
* Add example using VectorTable to demonstrate initialisation and interrupt function registration
- Clippy warns about empty loops, https://github.com/rust-lang/rust-clippy/issues/6161
- wfi allows to CPU to save some power
WFI was avoided in examples for fear of ill interactions with debuggers.
However the rp2040 debug port does continue to work, as long as the
relevant clocks are not disabled in SLEEP_EN0/SLEEP_EN1. (By default,
all clocks stay enabled in sleep mode.)
This patch replaces several different workarounds with just calling wfi.
Implementing `impl From<SystemClock> for Hertz` is a footgun, as
SystemClock is not Copy, so the automatic conversion consumes the
owned clock.
This is visible in the example i2c.rs:
```
let mut i2c = hal::I2C::i2c1(
pac.I2C1,
sda_pin,
scl_pin, // Try `not_an_scl_pin` here
400.kHz(),
&mut pac.RESETS,
clocks.peripheral_clock,
);
```
If the user wants to use both `i2c0` and `i2c1` at the same time,
copying from this example won't work:
```
error[E0382]: use of moved value: `clocks.peripheral_clock`
--> rp2040-hal/examples/i2c.rs:106:9
|
97 | clocks.peripheral_clock,
| ----------------------- value moved here
...
106 | clocks.peripheral_clock,
| ^^^^^^^^^^^^^^^^^^^^^^^ value used here after move
|
= note: move occurs because `clocks.peripheral_clock` has type
`PeripheralClock`, which does not implement the `Copy` trait
```
As getting the frequency from a clock doesn't really need ownership,
changing it to `impl From<&SystemClock> for Hertz` is both more
logical and provides better usability.
This is, however, a breaking change: Code relying on this trait
implementation needs to be changed by adding a `&`.
* add example of synchronized PIOs
* Synchronize state machines using WAIT IRQ instruction
* Use "irq wait 0" instead of "wait 1 irq 0"
This way, the initial value of the interrupt flag doesn't matter
* Start state machines synchronized without IRQ WAIT instruction
* Improve API
Co-authored-by: Andrew Straw <strawman@astraw.com>
* Update changelog for 0.4.0 release
* Enable rt feature for irq example in Cargo.toml
* Bump pio/pio-proc deps to 0.2.0, update pio examples
* Update BSPs to latest ws2812-pio, remove unused pio dep
* Fix usage of pio_proc in doc comment
* Clean up pio doc-example
* Update rp-pico to latest i2c-pio
Co-authored-by: Jan Niehusmann <jan@gondor.com>
Make all ROM functions (normal and floating point) provide both a direct
call that does the operation and a module with a ptr() function to get
the function pointer.
* Add basic multicore fifo example
* Add documentation for multicore
* Send system_clock frequency to core1 over FIFO in example
* Add Stack::new() to HAL. Use Stack::new() in example
* Implements methods to allow presetting the pin state & direction
Enabling those methods allows to save a few valuable instructions
in the PIO's memory.
* Update pio_proc_blink with new set_pindirs