Commit Graph

729 Commits

Author SHA1 Message Date
8c9e50b378 Conflates the negative and positive types as they are the same, and renames pin to input as they can be more than pins 2021-10-11 09:38:35 +11:00
b043778f75 Removed the NotConnected as it isn't used. 2021-10-11 09:08:58 +11:00
25d6a2cd13 No use case understood for NotConnected, so hiding it for now 2021-10-11 08:56:53 +11:00
617a976e96 No need for unwrap 2021-10-11 08:54:24 +11:00
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
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
0e05ba688d nrf/saadc: remove Sample trait. 2021-10-07 02:10:22 +02:00
ead987245d embassy: Refactor module structure to remove kitchen-sink util. 2021-09-11 02:35:35 +02:00
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
d0c8749399 Merge pull request #382 from fnafnio/typestate_nrf_timer
Typestate nrf timer
2021-09-02 13:39:55 +02:00
34c66fa78d removed type aliases
NotAwaitable as default generic param
added awaitable_timer example
2021-09-02 12:02:31 +02:00
a81b963561 nrf/saadc: don't use wake_on_interrupt. 2021-09-01 23:54:26 +02:00
1cef7134d4 moved CC::wait to awaitable typestate 2021-09-01 16:20:32 +02:00
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
7c0990ad1e time: allow storing state inside the driver struct. 2021-08-25 21:06:27 +02:00
ed1ed5225f Expose EASY_DMA_SIZE. 2021-08-22 00:23:03 +01:00
3457bb9f05 nrf: make gpiote and time-driver optional via cargo features. 2021-08-20 15:42:42 +02:00
17659e2e44 nrf/wdt: add handle steal 2021-08-20 14:23:24 +02:00
066abfe4c6 nrf/time: allow configuring the rtc irq prio 2021-08-18 22:13:02 +02:00
2540a960e5 nrf: add WDT driver 2021-08-07 14:26:28 +02:00
05e50e1f4a time_driver: use regular fn ptr -> raw ptr casts 2021-08-05 19:19:47 +02:00
0ea6a2d890 time: replace dyn clock/alarm with a global Driver trait 2021-08-05 19:14:09 +02:00
07d4b196f7 Update nightly, remove removed features. 2021-08-04 19:48:14 +02:00
3f28bb6c77 common: Initialize PeripheralMutex state with closure to ensure it's done in-place. 2021-08-02 20:13:41 +02:00
af87031d62 hal-common: remove Pin in PeripheralMutex 2021-08-02 19:55:04 +02:00
7bfb763e09 Rename embassy-extras to embassy-hal-common 2021-07-29 13:44:51 +02:00
c8a48d726a Merge pull request #277 from Liamolucko/fix-peripheral-ub
extras: Fix UB in `Peripheral`
2021-07-29 13:08:30 +02:00
d5ba35424d Replace PeripheralStateUnchecked with register_interrupt_unchecked 2021-07-29 15:11:26 +10:00
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
1b7ad7080e Add Send/Sync bounds to PeripheralState 2021-07-24 12:53:57 +10:00
58edefff6e Formatting. 2021-07-23 13:22:39 -04:00
d5ed5c3ef3 Split up the nRF impls for SPI traits. 2021-07-23 13:22:39 -04:00
f916fe5476 all hals: reexport PAC if unstable-pac feature is set. 2021-07-14 22:19:04 +02:00
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
7ebd4e3aa9 nrf/gpio: fix unused warning on chips without ports 2021-07-05 02:44:16 +02:00
e55c89f890 Merge pull request #262 from Liamolucko/nrf-rng
Add an nRF RNG driver
2021-07-01 01:55:55 +02:00
99339e940e fix: check if new_ptr == end, not the old pointer 2021-06-30 16:04:34 +10:00
53b95588df Use atomics to share state instead of a RefCell 2021-06-30 15:55:52 +10:00
89fdad3a6b Don't wake the future for every byte in fill_bytes 2021-06-30 12:34:57 +10:00
ae0219de6f Move initialisation inside of future 2021-06-30 09:45:49 +10:00
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
c0ef40d6e9 Correctly unset bits 2021-06-29 15:12:42 +10:00
e6d0dba5ca Write bits directly to intenset/clr + shorts 2021-06-29 14:37:37 +10:00
87ca902e44 Handle differences between PACs 2021-06-29 13:04:05 +10:00
0c0597f775 Don't include extended timer support on chips without it 2021-06-29 12:07:10 +10:00
94e13ef053 Fix Cc::event_compare 2021-06-29 11:39:50 +10:00
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
e7addf094b Fix Cc::wait never resolving and refactor some APIs
I think the interrupt was getting immediately re-triggered as soon as the handler exited, so I disabled the interrupt in the handler.
2021-06-29 10:33:41 +10:00
02781ed744 Add an nRF Timer driver
Resolves #189
2021-06-26 17:58:36 +10:00
e9bd8428e3 embassy-nrf: twim derive defmt 2021-06-07 19:09:03 -07:00