Commit graph

39 commits

Author SHA1 Message Date
Jan Niehusmann b81ad6f599 Use UartConfig::new constructor instead of common_configs in examples 2022-10-15 17:14:43 +00:00
Wilfried Chauveau 305dfc9d1f
Add rtic-monotonic support for timer & alarms (feature gated) (#459)
* Add rtic-monotonic support for timer & alarms
* Force Alarm interrupt if timer is set too soon
* timer: Remove non_exhaustive attribute from ScheduleAlarmError
* timer: TooSoon is no longer emitted so it can be removed
2022-10-06 18:31:31 +01: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 5ce10ff94e
timer: Use a fixed type in Alarm::schedule (#442) 2022-08-31 21:45:08 +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 3261eccd4d
Fix interpolator example post migration to fugit (#434) 2022-08-26 02:32:24 +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
Wilfried Chauveau 93ec18be07 migrate rp2040-hal from embedded_time to fugit 2022-08-24 22:46:34 +01:00
Wilfried Chauveau 42e929d7e1
Use rp2040-hal in all example (possibly through their bsp) (#423)
* 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.
2022-08-21 19:01:45 +01:00
Wilfried Chauveau 51db37a4cb
replace cortex_m::interrupt::Mutex with critical_section::Mutex in examples (#422) 2022-08-21 19:00:57 +01: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
Alexandria 26356428bf
Update pico_usb_twitchy_mouse.rs
typo
2022-08-12 16:08:46 -07: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 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
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
9names 895bae90b5
Merge pull request #324 from 9names/bsp_use_hal_entry_macro
Add reexport of rp2040::entry to BSPs
2022-05-31 23:41:45 +10:00
paddywwoof f8720fcbd2
Port HD44780 display example from rp2040-hal to rp-pico (#347) 2022-05-31 23:08:02 +10:00
luca zulian 3842ef2700
Add Pico PWM micro servo example (#346)
* Add micro servo with pwm working example

Signed-off-by: lucazulian <lucagiuggia@gmail.com>

* Add duty value suggestion

Signed-off-by: lucazulian <lucagiuggia@gmail.com>

* Fix code formatting

* Use CountDown instead of Delay
2022-05-26 22:25:49 +10:00
Jan Niehusmann db1b5d36b5 Set device_class of twitchy_mouse example to 0
This fixes the mouse on Mac.

Closes #327
2022-05-16 22:32:08 +10:00
Jordan Williams cf86e08749
Add the Pimoroni Plasma 2040 board (#337)
* Add the Pimoroni Plasma 2040 board

This PR adds the board support package and a simple example.
The example just blinks the on-board RGB LED.

An example should be added for using the board to control an LED strip.
This should probably use smart-leds with the associated PIO driver.

An example or functionality should be added for the current sensor.

* Rename LED data line from dat to data to match schematic

* Add an example for driving WS2812 LEDs

This is pretty much a copy-paste of the awesome pico_ws2812_led example.

* Remove reference in README to rp-pico

* Remove reference to pico board clock speed

I have removed this in the Plasma 2040 repository and where I copied it from, tiny2040_blinky.

* Remove redundant namespace

* Add self-reference in README to the current board's GitHub README

Fix the erroneous link in the pimoroni-tiny2040 README from which I copied.
2022-05-12 11:17:11 +10:00
mqy 623457a498 fixed typos 2022-04-30 12:51:45 +10:00
Wilfried Chauveau bb07402fc9 Abstract alarms 2022-04-30 11:54:54 +10:00
9names e9a4f7e40b Update rtic example to reset spinlocks in init 2022-04-30 11:33:22 +10:00
9names 12cbab967c Update all BSP examples to use the BSP's re-exported entry macro 2022-04-10 21:54:56 +10:00
Jonathan 'theJPster' Pallant 8bdecd2058
Merge pull request #283 from Sizurka/rom-functions
Improve ROM function access
2022-02-04 09:53:59 +00:00
Derek Hageman a6daaf9fa3 Standardize ROM function access
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.
2022-02-03 13:32:18 -07:00
9names f51a84f070 Use new alarm syntax in pico_rtic example 2022-01-30 23:04:16 +11:00
Weird Constructor 3f9535cc1f Cleaned up the code and made it more idiomatic. 2022-01-12 21:48:22 +01:00
Weird Constructor e22540be20 Mention the assumed display size of 128x64. 2022-01-12 19:28:51 +01:00
Weird Constructor 2f1e77d0b2 Added documentation for the OLED example and fixed formatting. 2022-01-12 19:25:06 +01:00
Weird Constructor 2f418bbf8f Add an example for using the SSD1306 I2C display driver crate with the Raspberry Pi Pico 2022-01-12 19:25:06 +01:00
Weird Constructor 5b07c09cfb Removed weird rom function usage, reformulated comments and cleaned up hsv2rgb() code. 2022-01-09 22:02:31 +01:00
Weird Constructor 2b49bc6b60 Add Raspberry Pi Pico WS2812 LED example 2022-01-09 15:27:29 +01:00
Weird Constructor 0e3136da11
Add an example for accessing an SD/MMC card via SPI (#258) 2022-01-10 00:16:35 +11:00
9names 0e1fe81384 Remove static BOOT2 decl in BSP examples so they build 2022-01-03 23:07:03 +11:00
Jonathan Pallant 7da16a726f Fixing typos spotted in the review. 2021-12-26 19:39:16 +00:00
Jonathan Pallant (Ferrous Systems) d3bd232885 Added two UART IRQ examples.
They are in the pico BSP as they need the 'rt' feature. Also includes
changes to the UART driver for enabling/disabling interrupts.
2021-12-26 19:33:23 +00:00
Victor Koenders 86444448a4
Migrated examples to the new uart system 2021-12-25 09:46:40 +01:00
Jonathan Pallant (Ferrous Systems) 8f0a2788eb Renamed pico to rp-pico. 2021-12-23 11:18:52 +00:00