Commit graph

353 commits

Author SHA1 Message Date
Jan Niehusmann fcd6f7c19d Remove unnecessary custom Infallible types 2022-09-28 21:59:09 +00:00
Jan Niehusmann e4deaabb51 Upgraded embedded-hal alpha dependency to 1.0.0-alpha.9
For now, disabled non-blocking implementations.
2022-09-28 21:59:09 +00:00
Jan Niehusmann 8d9b4538c9
Merge pull request #453 from jannic/update-jmp-offset
simplify jump offset calculation when loading PIO programs
2022-09-27 22:25:22 +02:00
Olivier 69c047136c added SPI is_busy function 2022-09-19 15:27:46 +02:00
Jan Niehusmann 6a5747b213 Use u8 instead of usize for pio address calculation 2022-09-18 10:48:09 +00:00
Jan Niehusmann 7cca9a71d7 simplify jump offset calculation when loading PIO programs 2022-09-17 17:22:34 +00:00
Jan Niehusmann fa83510277 Provide rp2040_hal::gpio::pin::Pin::into_push_pull_output_in_state 2022-09-17 13:31:11 +00:00
Jan Niehusmann cbed25944a
Merge pull request #449 from papyDoctor/main
Added set_fifos/set_rx_watermark/set_tx_watermark
2022-09-17 10:25:52 +02:00
Wilfried Chauveau 4ddad4e74c
fix concurrent accesses to sm_execctrl and sm_instr when sideset isn't optional (#448)
* fix concurrent accesses to sm_execctrl and sm_instr when sideset isn't optional
* review & document unsafe blocks
2022-09-16 17:19:54 +01:00
Wilfried Chauveau 322bba2cc0
pio: Move interrupt related (en|dis)abling/forcing methods to the statemachine (#447)
* pio: Move interrupt related (en|dis)abling/forcing methods to the statemachine

The SM knows its id using the type system so there's no need for checking it.
This commit also adds a `PioIRQ` enum to select the output IRQ.

* Move the interrupt control to Rx & Tx and make all accesses to inte atomic
* Adjust the ergonomics of IRQ handling.
* Elide lifetimes where they can be (clippy's advice)
2022-09-14 21:07:03 +01:00
Wilfried Chauveau 42fc266e67
timer: Mark Timer & Alarm* Send and Sync (#451) 2022-09-14 21:06:08 +01:00
Olivier b29cc2630c Added set_fifos/set_rx_watermark/set_tx_watermark
that permit to enable/disable the Rx/Tx FIFOs and to set
the watermarks for the DMA/interrupts triggering
2022-09-12 17:06:27 +02:00
Wilfried Chauveau 5ce10ff94e
timer: Use a fixed type in Alarm::schedule (#442) 2022-08-31 21:45:08 +01:00
Wilfried Chauveau 0e2b4cf7be
Add a method to allow setting the PIO's clock divisor without floats (#440)
* pio: Changes `PIOBuilder::clock_divisor` from f32 to fixed point)
* pio: mark clock_divisor as deprecated
2022-08-31 21:44:53 +01:00
Wilfried Chauveau 6d75cd8291
usb: Use the dedicated write_bitmask_* functions (#441) 2022-08-31 13:41:35 +01:00
Wilfried Chauveau 4dbd5667a6
Use TimerInstant in Timer::GetCounter & add Alarm::schedule_at (#439) 2022-08-31 06:54:57 +01:00
Wilfried Chauveau dbc691fb09
Temporary disable sticky-bit in set_pins too (#433) 2022-08-25 18:19:01 +01:00
Kasil 31469c232f
Add support for the Interpolator (#371)
* Implementation of the interpolator.
* corrected formatting
* fixed documentation code
* add clamp flag to LaneCtrl
* addition of an example for the interpolator
* put documentation behind ///
* rewording comment for clarity
* using more idiomatic fn new
2022-08-25 18:02:56 +01:00
Jan Niehusmann 00f5e8d184
Merge pull request #432 from jannic/fix-set_pindirs
Temporarily disable out_sticky in set_pindirs
2022-08-25 12:02:55 +02:00
Jan Niehusmann 6b0ea14ec1 Temporarily disable out_sticky in set_pindirs
Otherwise, it will change unrelated pindirs as well, if sticky is set
2022-08-25 07:49:59 +00:00
Wilfried Chauveau 47d8f4fc21
Add Debug and defmt::Format to the public types of rp2040_hal::gpio::dynpin (#431) 2022-08-25 05:54:26 +01:00
Wilfried Chauveau 93ec18be07 migrate rp2040-hal from embedded_time to fugit 2022-08-24 22:46:34 +01:00
Wilfried Chauveau 6a29b3bb73 Make the i2c error render as text if eh1_0_alpha is on. 2022-08-24 18:23:16 +01:00
camrbuss fea35b48bb doc: fix clocks extended usage xosc order 2022-08-21 02:51:53 -04:00
Jan Niehusmann c1c5e05989 Feature-gate critical-section-impl
For compatibility with earlier versions, this feature is activated by
default. This decision can be revisited later.
2022-08-18 06:35:04 +00:00
Jan Niehusmann b4d0d613e3 Update to critical-section 1.0.0 2022-08-18 06:34:28 +00:00
Wilfried Chauveau 7bfab4ffd2
Implements USB enumeration workaround (RP2040-E5). (#120)
* Implement rp2040-E5 workaround for usb enumeration.

* Expand documentation and add to pico_usb_serial & pico_usb_twitchy_mouse

* Fix errata-5 documentation around the bus-keep state.

* Update CHANGELOG.md
2022-08-17 22:22:36 +01: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
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 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 1be329a907
Merge pull request #407 from FlorianUekermann/main
Implement NonPwmPinMode for gpio::Disabled
2022-08-02 21:46:18 +02: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
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
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 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
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
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
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
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
Jan Niehusmann 99dfeaf6f2
Implement embedded-hal 1.0.0-alpha.8 traits (#366)
* Implement embedded-hal 1.0.0-alpha.8 traits

* Add comment about missing SPI traits
2022-06-24 08:19:41 +10:00
Hmvp f7cfeec0d7
Add bsp_pin example (#364) 2022-06-23 21:10:58 +10:00
Hmvp 0f114677d5
Explorer base improvements (#363)
* Improve comments

* Expose pins and all pins naming struct.

This allows users to set the interrupts on the button pins and to skip the PicoExplorer struct but still use proper naming

* Use correct interrupt names in timer::alarms macro in HAL
2022-06-23 19:19:32 +10:00