Commit graph

769 commits

Author SHA1 Message Date
Wilfried Chauveau 082281b10b
Use matrix in GHA workflow to reduce duplication 2022-08-13 17:22:04 +01:00
Jan Niehusmann 7e178acde5
Merge pull request #419 from alxpettit/patch-1
Fix typo
2022-08-13 07:16:06 +02:00
Alexandria 26356428bf
Update pico_usb_twitchy_mouse.rs
typo
2022-08-12 16:08:46 -07:00
Wilfried Chauveau f10c73f4fa
Add meaningful names to steps and remove quasi-repetition
The workflow only shows "Runs action-rs/cargo@v1" which does not tell us
much about what's actually being done.
The list and clean up done after each build varies by only the debug/release
part of the path that is repeated several times (2).

This commit gives each step a more meaningful name and simplify the list &
cleanup step with a generic one liner that can be copy/pasted without
modification.
2022-08-12 12:50:07 +01:00
Jan Niehusmann fbba3755ff
Merge pull request #417 from jannic/clippy
Fix clippy warnings
2022-08-12 00:22:27 +02:00
Jan Niehusmann c1df2bea2b Fix clippy warnings
Fixes a few instances of derive-partial-eq-without-eq and needless-borrow
clippy warnings.
2022-08-11 21:45:26 +00:00
Jan Niehusmann 96e15ee6de
Merge pull request #415 from jannic/features-vector_table
Enable feature "rt" when compiling vector_table example
2022-08-11 19:21:07 +02:00
Jan Niehusmann e9a720ffab
Merge pull request #416 from jannic/generic-boot-loader
Use generic boot loader for rp2040-hal examples
2022-08-11 19:20:43 +02:00
Jan Niehusmann 0f33d2b8a6 Enable feature "rt" when compiling vector_table example
Without this change, building the vector_table example fails when
building from the rp2040-hal directory:

```
rp2040-hal$ cargo build --release --example vector_table
   Compiling rp2040-hal v0.5.0 (rp2040-hal)
error[E0432]: unresolved import `pac::interrupt`
  --> rp2040-hal/examples/vector_table.rs:30:5
   |
30 | use pac::interrupt;
   |     ^^^^^---------
   |     |    |
   |     |    help: a similar name exists in the module (notice the capitalization): `Interrupt`
   |     no `interrupt` in the root

error: cannot determine resolution for the attribute macro `interrupt`
   --> rp2040-hal/examples/vector_table.rs:148:3
    |
148 | #[interrupt]
    |   ^^^^^^^^^
    |
    = note: import resolution is stuck, try simplifying macro imports
```
2022-08-11 12:09:20 +00:00
Jan Niehusmann d4743061fa Use generic boot loader for rp2040-hal examples
Those examples should be independent of a specific board.
The generic boot loader increases their compatibility.
2022-08-11 11:56:41 +00:00
9names 2bbc52ffce
RAM-based interrupt vector tables (#321)
* 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
2022-08-06 14:58:43 +10:00
Jan Niehusmann 575aba4bfe
Merge pull request #408 from jannic/wfi
Use wfi in otherwise empty infinite loops in examples
2022-08-04 16:49:06 +02:00
Jan Niehusmann 62f1ab2159
Merge pull request #411 from jannic/fix-usb-sie_status
Fix clearing usb sie_status flags
2022-08-03 10:20:08 +02:00
Jan Niehusmann b636afb7b5 Clear sie_status.suspended / sie_status.resume flags in poll()
usb_device ignores PollResult::Suspend when already suspended,
and PollResult::Resume when not suspended.

This may lead to repeatedly triggered interrupts if for some reason
the Suspend flag gets set while the device is already suspended.

I observed such a situation when a reset was triggered while the device
was suspended.

To make sure that this can't cause interrupt storms, clear the flags
before returning from poll()
2022-08-02 22:17:54 +00:00
Jan Niehusmann 786062aa74 To clear a bit in sie_status, just write that single bit 2022-08-02 22:11:14 +00:00
Jan Niehusmann 5448a12b31
Merge pull request #398 from jannic/defmt-0.3
Update examples to defmt 0.3
2022-08-02 22:00:11 +02:00
Jan Niehusmann fb9bac5064
Merge pull request #410 from ithinuel/bump-usb-device-to-0-2-9
bump usb-device to 0.2.9
2022-08-02 21:58:17 +02:00
Jan Niehusmann 1be329a907
Merge pull request #407 from FlorianUekermann/main
Implement NonPwmPinMode for gpio::Disabled
2022-08-02 21:46:18 +02:00
Wilfried Chauveau 60677df099
bump usb-device to 0.2.9 2022-08-02 20:43:00 +01:00
Jan Niehusmann 44019781e2 Use wfi in otherwise empty infinite loops in examples
- 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.
2022-08-01 14:54:03 +00:00
Jan Niehusmann 6dafcc1ac0
Merge pull request #405 from ithinuel/fix-usb-ep0-out
Fix usb missed ep0 out packet and add recommended sync delays
2022-08-01 15:32:45 +02:00
Florian Uekermann 03e791ab31 Implement NonPwmPinMode for gpio::Disabled
Fixes #397
2022-08-01 15:20:54 +02:00
Jan Niehusmann dfaeba5315 Remove defmt dependencies from boards/vcc-gnd-yd-rp2040/Cargo.toml
Nothing in that crate depends on defmt
2022-07-31 15:35:49 +00:00
Jan Niehusmann 365ac70ae4 Fix building of examples which do not use defmt
Uses build.rs in board directories to set the linker options locally.
The file .cargo/config can't be used for that, as in a workspace the
local .cargo/config is ignored if the build is triggered from the
workspace root.
2022-07-31 15:35:49 +00:00
Jan Niehusmann b1fcb7eff8
Merge pull request #406 from ithinuel/add-suspend-and-remote-wakeup-support
Add suspend, resume and remote wakeup support.
2022-07-31 14:51:50 +02:00
Wilfried Chauveau 5dd095bd45
Add suspend, resume and remote wakeup support. 2022-07-30 20:51:01 +01:00
Wilfried Chauveau fa7c9275b4
Fix missed ep0-data-out transaction
The ep0-out buffer must not be marked as available unless required.
Otherwise, the controller will acknowledge the data-out packet but
won't reflect that in its status registers.

This patch forces the controller to nack the data-out phase until we have
processed the setup packet.
2022-07-30 10:09:20 +01:00
Wilfried Chauveau 067f1396d9
Add the required synchronisation delays
As per 4.1.2.5.1, the access to the DPSRAM should "be considered asynchronous
and not atomic".
It is recommended to write to buffer control register in two steps.
A first one to configure all bits but Available.
Wait clk_sys/clk_usb (typically 125MHz/48MHz).
Then set the available bit (if required).
2022-07-30 10:03:03 +01:00
Jan Niehusmann 6e325ba099
Remove unnecessary cortex_m::interrupt::free in timer.rs (#402)
The only thing accessed by those methods is `&mut self`, which is
guaranteed to be a unique reference. So an interrupt can not
interfere with the correctness of the operation.
2022-07-28 10:26:24 +10:00
9names c7acafda3c
GPIO IRQ example: add check for interrupt source (#401) 2022-07-28 10:14:20 +10:00
Jan Niehusmann 96552b28c5
Merge pull request #399 from jannic/issue_390
Fix handling of duty cycle while PWM channels is disabled
2022-07-26 15:09:16 +02:00
Jan Niehusmann c0c72c4db3 Fix handling of duty cycle while PWM channels is disabled
Fixes #390
2022-07-26 08:22:53 +00:00
Jan Niehusmann 46110c0d32 Update examples to defmt 0.3
Current version of probe-run is 0.3.3, which uses defmt 0.3.2.

With a firmware using defmt 0.2, this causes the following error
message:

```
Error: defmt wire format version mismatch: firmware is using 0.2, `probe-run` supports 3
suggestion: `cargo install` a different version of `probe-run` that supports defmt 0.2
```

Therefore, upgrade defmt dependency, and also fix the linker script
in .cargo/config.
2022-07-25 19:39:14 +00:00
Jan Niehusmann 32411b8652
Merge pull request #394 from jannic/use-ref-for-clock-to-herz
Implement conversion from Clock to Hertz using reference
2022-07-25 20:38:21 +02:00
Philip L. McMahon d0eaca63ef
Match Seeeduino XIAO pin name to function (#396) 2022-07-24 20:50:12 +10:00
Jan Niehusmann 595e0a9974 i2c is driven from system_clock, noch peripheral_clock. Update example accordingly. 2022-07-22 20:34:56 +00:00
Jan Niehusmann f8984a9eac Implement conversion from Clock to Hertz using reference
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 `&`.
2022-07-22 20:17:26 +00:00
9names 12387bcf09
Add docs and doc-example for Timer (#386) 2022-07-18 15:35:21 +10:00
nleguen b71dc3678b
Add BSP for VCC-GND YD-RP2040 (#388) 2022-07-18 15:35:00 +10:00
Jacob Ohpea 83b990ee30
Formatting Readme (#385) 2022-07-15 17:49:54 +10:00
9names 69c2dd2c2b
Initial BSP for Pimoroni Badger2040 (#334) 2022-07-11 19:45:44 +10:00
Jan Niehusmann 7d11e2f15e
Merge pull request #381 from 9names/adafruit_macropad_fix_speaker_pin
Fix pin number for speaker in adafruit macropad bsp
2022-07-10 13:04:41 +02:00
9names 5e4805ab2c Fix incorrect pin for speaker 2022-07-10 14:29:10 +10:00
Jan Niehusmann 3c4d8f0b43
Merge pull request #372 from 9names/fix_bsp_pins_docs
Add missing open paren in bsp_pins doc macro
2022-07-09 12:40:16 +02:00
Jan Niehusmann 0f5bc072cd
Use ignore instead of text (#378)
While the code block fails to compile, it's still code and not random text. Marking it with `ignore` allows for proper syntax highlighting, for example.

According to https://github.com/rust-lang/rust/issues/97030#issuecomment-1134499264 this is the proper fix, so this closes #374
2022-07-08 20:58:09 +10:00
Philip L. McMahon 803f582e0f
Add BSP for Seeeduino XIAO RP2040 (#369)
* Add BSP for Seeeduino XIAO RP2040

* Add missing link target

* Add top-level README mention of XIAO RP2040
2022-07-06 20:41:47 +10:00
9names 711694881d
Wrap intrinsics docstring to avoid breakage (#375)
* Wrap code in intrinsics docstring with a text block to fix CI breakage
2022-07-06 19:52:31 +10:00
9names 319c1749fc Fix unmatched parens in bsp_pins doc macro 2022-06-28 22:00:58 +10:00
Hmvp b12aecb51c
Add pio pwm example (#365)
* Add pio pwm example

This adds a more advance pio example which uses side set and instruction injection
2022-06-26 22:11:41 +10:00
Jan Niehusmann e5897ca7a4
Fix PIO rx fifo status (#367)
* Implement embedded-hal 1.0.0-alpha.8 traits

* Add comment about missing SPI traits

* Fix doc of rx.is_empty() and add rx.is_full()
2022-06-24 08:24:27 +10:00