Commit Graph

237 Commits

Author SHA1 Message Date
huntc
5f5470a320 Need to borrow the pins for the lifetime of the config, and subsequently the one shot. 2021-10-11 08:52:45 +11:00
huntc
cef6158c31 Extend SAADC one shot support
One-shot mode now permits the sampling of differential pins, and the sampling of multiple pins simultaneously.

A new ChannelConfig structure has been introduced so that multiple channels can be configured individually. Further, the `sample` method now accepts a buffer into which samples are written.

Along the way, I've reset some default configuration to align with Nordic's settings in their nrfx saadc driver. Specifically, the channel gain defaults to 6 (from 4) and the time defaults to 10us (from 20us).
2021-10-09 11:25:18 +11:00
Dario Nieuwenhuis
0e05ba688d nrf/saadc: remove Sample trait. 2021-10-07 02:10:22 +02:00
Ulf Lilleengen
99a94f1d50 Update version of critical-section 2021-09-13 17:05:17 +02:00
Ulf Lilleengen
e24528051b Add WASM support for executor
* Adds an executor for WASM runtimes based on wasm_bindgen.
* Add time driver based on JS time handling.
* Add example that can run in browser locally.
* Update to critical-section version that supports 'std' flag
2021-09-13 16:42:39 +02:00
Dario Nieuwenhuis
ead987245d embassy: Refactor module structure to remove kitchen-sink util. 2021-09-11 02:35:35 +02:00
Dario Nieuwenhuis
f2623e7e9b Update lots of deps 2021-09-11 01:35:23 +02:00
Dario Nieuwenhuis
de016e8456 Remove trait_alias, allow(incomplete_features).
trait_alias seems unused. no idea why it's there.
2021-09-03 17:00:58 +02:00
Dario Nieuwenhuis
d0c8749399
Merge pull request #382 from fnafnio/typestate_nrf_timer
Typestate nrf timer
2021-09-02 13:39:55 +02:00
f_punk
34c66fa78d removed type aliases
NotAwaitable as default generic param
added awaitable_timer example
2021-09-02 12:02:31 +02:00
Dario Nieuwenhuis
a81b963561 nrf/saadc: don't use wake_on_interrupt. 2021-09-01 23:54:26 +02:00
f_punk
1cef7134d4 moved CC::wait to awaitable typestate 2021-09-01 16:20:32 +02:00
f_punk
a0c40562ea added typestate to nrf-Timer
useful for hooking up the PPI to an Event without needing interrupt
tested with buffered_uart example on nRF52840-DK
2021-09-01 16:16:56 +02:00
Dario Nieuwenhuis
7c0990ad1e time: allow storing state inside the driver struct. 2021-08-25 21:06:27 +02:00
Richard Dodd
ed1ed5225f Expose EASY_DMA_SIZE. 2021-08-22 00:23:03 +01:00
Dario Nieuwenhuis
3457bb9f05 nrf: make gpiote and time-driver optional via cargo features. 2021-08-20 15:42:42 +02:00
Dario Nieuwenhuis
17659e2e44 nrf/wdt: add handle steal 2021-08-20 14:23:24 +02:00
Dario Nieuwenhuis
fe355af4f0 nrf: update to cortex-m-rt 0.7 2021-08-19 17:11:17 +02:00
Dario Nieuwenhuis
d3aeb45fb3 Update cortex-m-rt to v0.7 for stm32, rp. 2021-08-19 00:56:11 +02:00
Dario Nieuwenhuis
066abfe4c6 nrf/time: allow configuring the rtc irq prio 2021-08-18 22:13:02 +02:00
Dario Nieuwenhuis
2540a960e5 nrf: add WDT driver 2021-08-07 14:26:28 +02:00
Dario Nieuwenhuis
452f7e0c2c nrf: update PACs to 0.10 2021-08-07 12:41:12 +02:00
Dario Nieuwenhuis
05e50e1f4a time_driver: use regular fn ptr -> raw ptr casts 2021-08-05 19:19:47 +02:00
Dario Nieuwenhuis
0ea6a2d890 time: replace dyn clock/alarm with a global Driver trait 2021-08-05 19:14:09 +02:00
Dario Nieuwenhuis
07d4b196f7 Update nightly, remove removed features. 2021-08-04 19:48:14 +02:00
Dario Nieuwenhuis
3f28bb6c77 common: Initialize PeripheralMutex state with closure to ensure it's done in-place. 2021-08-02 20:13:41 +02:00
Dario Nieuwenhuis
af87031d62 hal-common: remove Pin in PeripheralMutex 2021-08-02 19:55:04 +02:00
Dario Nieuwenhuis
7bfb763e09 Rename embassy-extras to embassy-hal-common 2021-07-29 13:44:51 +02:00
Dario Nieuwenhuis
c8a48d726a
Merge pull request #277 from Liamolucko/fix-peripheral-ub
extras: Fix UB in `Peripheral`
2021-07-29 13:08:30 +02:00
Liam Murphy
d5ba35424d Replace PeripheralStateUnchecked with register_interrupt_unchecked 2021-07-29 15:11:26 +10:00
Liam Murphy
079526559f Remove critical sections from PeripheralMutex interrupt handler by checking the interrupt's priority on startup.
Since `PeripheralMutex` is the only way to safely maintain state across interrupts, and it no longer allows setting the interrupt's priority, the priority changing isn't a concern.

This also prevents other causes of UB due to the interrupt being exposed during `with`, and allowing enabling the interrupt and setting its context to a bogus pointer.
2021-07-27 17:28:52 +10:00
Liam Murphy
1b7ad7080e Add Send/Sync bounds to PeripheralState 2021-07-24 12:53:57 +10:00
Bob McWhirter
58edefff6e Formatting. 2021-07-23 13:22:39 -04:00
Bob McWhirter
d5ed5c3ef3 Split up the nRF impls for SPI traits. 2021-07-23 13:22:39 -04:00
Dario Nieuwenhuis
f916fe5476 all hals: reexport PAC if unstable-pac feature is set. 2021-07-14 22:19:04 +02:00
Dario Nieuwenhuis
35a76c364a embassy/time: make optional via Cargo feature 2021-07-12 03:45:48 +02:00
Liam Murphy
744e2cbb8a extras: Fix UB in Peripheral
`Peripheral` assumed that interrupts can't be preempted,
when they can be preempted by higher priority interrupts.
So I put the interrupt handler inside a critical section,
and also added checks for whether the state had been dropped
before the critical section was entered.

I also added a `'static` bound to `PeripheralState`,
since `Pin` only guarantees that the memory it directly references
will not be invalidated.
It doesn't guarantee that memory its pointee references also won't be invalidated.

There were already some implementations of `PeripheralState`
that weren't `'static`, though,
so I added an unsafe `PeripheralStateUnchecked` trait
and forwarded the `unsafe` to the constructors of the implementors.
2021-07-05 17:42:43 +10:00
Dario Nieuwenhuis
7ebd4e3aa9 nrf/gpio: fix unused warning on chips without ports 2021-07-05 02:44:16 +02:00
Dario Nieuwenhuis
e55c89f890
Merge pull request #262 from Liamolucko/nrf-rng
Add an nRF RNG driver
2021-07-01 01:55:55 +02:00
Liam Murphy
99339e940e fix: check if new_ptr == end, not the old pointer 2021-06-30 16:04:34 +10:00
Liam Murphy
53b95588df Use atomics to share state instead of a RefCell 2021-06-30 15:55:52 +10:00
Liam Murphy
89fdad3a6b Don't wake the future for every byte in fill_bytes 2021-06-30 12:34:57 +10:00
Liam Murphy
ae0219de6f Move initialisation inside of future 2021-06-30 09:45:49 +10:00
Liam Murphy
8a4ab29819 Add an nRF RNG driver
Resolves #187

Like the stm32 driver, this has both a non-blocking and blocking API, and implements `rand_core::RngCore` for the blocking API.
2021-06-29 17:26:16 +10:00
Liam Murphy
c0ef40d6e9 Correctly unset bits 2021-06-29 15:12:42 +10:00
Liam Murphy
e6d0dba5ca Write bits directly to intenset/clr + shorts 2021-06-29 14:37:37 +10:00
Liam Murphy
87ca902e44 Handle differences between PACs 2021-06-29 13:04:05 +10:00
Liam Murphy
0c0597f775 Don't include extended timer support on chips without it 2021-06-29 12:07:10 +10:00
Liam Murphy
94e13ef053 Fix Cc::event_compare 2021-06-29 11:39:50 +10:00
Liam Murphy
e5a5031f20 Get rid of the TODO about variant names, stop the timer before setting BITMODE and set a default frequency. 2021-06-29 11:29:32 +10:00