Commit Graph

516 Commits

Author SHA1 Message Date
Dario Nieuwenhuis
42abeca493 nrf/spim: disable and deconfigure pins on drop. 2021-05-26 20:11:23 +02:00
Dario Nieuwenhuis
39c420733f nrf/uarte: deconfigure pins on drop 2021-05-26 20:11:23 +02:00
Dario Nieuwenhuis
8dfb6dff86 nrf/twim: make pullup configurable, do not enable it by default. 2021-05-26 20:11:23 +02:00
Dario Nieuwenhuis
b449f6de9d nrf/twim: deconfigure pins on drop 2021-05-26 18:23:10 +02:00
Dario Nieuwenhuis
55c3ba2a5f nrf/saadc: do not use dyn 2021-05-22 15:42:14 +02:00
Ulf Lilleengen
13524080d3 Avoid using full GAT 2021-05-22 13:23:09 +02:00
Ulf Lilleengen
f6cac6944c Makes it possible to use the ADC with different analog pins 2021-05-21 13:12:27 +02:00
Dario Nieuwenhuis
105c8504b6 Mark Unborrow as unsafe to implement 2021-05-19 23:29:33 +02:00
Dario Nieuwenhuis
e3ab02c7e3 nrf/saadc: remove Pin 2021-05-19 20:22:15 +02:00
Dario Nieuwenhuis
58723a8e76
Merge pull request #185 from embassy-rs/nrf-improvement
nrf improvements
2021-05-17 22:48:36 +02:00
Dario Nieuwenhuis
32fc17f0fd nrf/gpiote: Allow choosing IRQ priority. 2021-05-17 21:27:27 +02:00
Rukai
3e83acc1cb Fix unused field warnings 2021-05-17 20:23:04 +10:00
Rukai
149ddf2f29 Fix warnings 2021-05-17 19:48:58 +10:00
Dario Nieuwenhuis
f7858631d8 stm32: fix build, add ci 2021-05-17 03:16:58 +02:00
Dario Nieuwenhuis
a5ad79927e nrf: add Unborrow<Target = Self> bound to all instance traits 2021-05-17 01:01:31 +02:00
Dario Nieuwenhuis
8394603ea6 nrf/pwm: add enable/disable 2021-05-17 00:57:37 +02:00
Dario Nieuwenhuis
88f664b434 nrf/pwm: set initial value to Low, according to the PS 2021-05-17 00:57:37 +02:00
Dario Nieuwenhuis
f9bcf6df6b nrf: add PWM 2021-05-17 00:57:37 +02:00
Dario Nieuwenhuis
0310e4d458 Add init fn. Initializes hw and returns Peripherals. 2021-05-17 00:57:37 +02:00
Dario Nieuwenhuis
97b01f1c47 nrf/gpiote: initialize automatically 2021-05-17 00:57:20 +02:00
Dario Nieuwenhuis
92be72e0e3 Add #[interrupt] macro to register static interrupts. 2021-05-17 00:57:20 +02:00
Dario Nieuwenhuis
eb4571dc4c nrf: add blocking TWIM 2021-05-17 00:57:20 +02:00
Dario Nieuwenhuis
bd9589d0ce nrf: add support for nrf52805, nrf52811, nrf52820 2021-05-17 00:57:20 +02:00
Dario Nieuwenhuis
e0809ab0fb Switch to use PrioritX enums. 2021-05-11 01:34:24 +02:00
Dario Nieuwenhuis
7fa0e57172 Use critical_section crate 2021-05-11 01:15:30 +02:00
Ulf Lilleengen
0a3c236510 Improve comment 2021-05-10 23:06:25 +02:00
Ulf Lilleengen
e9eb3ce6c1 Disable PPI trigger during normal read 2021-05-10 23:06:25 +02:00
Ulf Lilleengen
687dda106f Read rx amount outside of poll_fn 2021-05-10 23:06:25 +02:00
Ulf Lilleengen
5afe01617a Use rxdrdy as trigger for timer 2021-05-10 23:06:25 +02:00
Ulf Lilleengen
dda338cedb Add implementation of ReadUntilIdle for nRF UART
Add type UarteWithIdle that implements Read, Write and ReadUntilIdle
traits. The type uses a timer + 2 PPI channels internally, triggered on
RTXSTARTED event.
2021-05-10 23:06:25 +02:00
Dario Nieuwenhuis
76f737bb0e
Merge pull request #158 from derekdreery/blocking_spim
Implement the blocking hal api for SPIM.
2021-05-05 22:52:36 +02:00
Richard Dodd
212e83aa22 Make changes to Write as well as Transfer 2021-05-05 19:18:57 +01:00
Richard Dodd
9d427a1ba4 Address issues in PR
Also add some documentation.
2021-05-05 18:33:45 +01:00
Richard Dodd
9de12a0a7a Address issues in PR. 2021-05-05 18:25:14 +01:00
Richard Dodd
1ad18aa09a Implement the blocking hal api for SPIM. 2021-05-05 14:50:28 +01:00
Richard Dodd
0b3ccca69b Add a pin variant that can change between disconnected/input/output.
I'm in no way attached to the name and encourage better suggestions.
2021-05-05 14:46:51 +01:00
Ulf Lilleengen
e2ad5e1395 Add detection of edge transitions for ports 2021-04-16 07:58:24 +02:00
Dario Nieuwenhuis
97ca54fa66 Rename PeripheralBorrow to Unborrow 2021-04-14 19:59:52 +02:00
Dario Nieuwenhuis
5ee87cf25d Remove Pin from Flash trait 2021-04-14 17:04:40 +02:00
Dario Nieuwenhuis
c15411d1bd Remove Pin from SPI 2021-04-14 17:04:40 +02:00
Dario Nieuwenhuis
8b1ffb2cb7 Remove Pin from GPIO traits 2021-04-14 17:04:40 +02:00
Dario Nieuwenhuis
59ccc45f28 Remove pin from Uart 2021-04-14 17:04:40 +02:00
Dario Nieuwenhuis
402f7f1886 nrf/gpio: remove DummyPin 2021-04-10 01:48:37 +02:00
Dario Nieuwenhuis
5b74e326e5 nrf/qpsi: make config non_exhaustive 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
b9e709403d nrf: better macro naming. 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
48cf1f6ebf nrf/system: add configure 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
3a18373828 nrf/uarte: update BufferedUarte to new APi 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
00e5f30352 nrf/ppi: add AnyConfigurableChannel 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
31b817ed27 nrf/timer: add instance traits 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
aa0341056e nrf/uarte: deal with hwfc correctly 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
b6496a85d8 nrf/ppi: implement and add example 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
26705ec328 nrf/ppi: add peris and traits 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
646be40ac5 nrf/gpiote: make number() public, change to usize 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
90f599bc2f nrf/gpiote: update output channel to new API 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
2bd9323f28 nrf/gpiote: update input channel to new API 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
a338841797 extras: add impl_unborrow macro 2021-03-29 00:58:58 +02:00
Richard Dodd
2c248dab56 nrf/spim: make mosi,miso optional 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
5646926cca nrf/rtc: update to new api 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
3eccddc44d nrf/uarte: use rxstarted/txstarted events to track whether a wait for stop is necessary on drop. 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
1c9f98e1b6 nrf/gpiote: fix irq race condition
The interrupt could fire between checking if sense=disabled and registering the waker,
in which case the future would get stuck.
2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
7a41541ab2 nrf/uarte: use Peripheral, wait for stop on drop. 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
0e8bb5dc0b util: Do not unregister waker on wake in AtomicWaker. 2021-03-29 00:58:58 +02:00
Richard Dodd
53645d9d38 nrf/saadc: initial implementation 2021-03-29 00:58:58 +02:00
Richard Dodd
a08d781442 nrf/gpio: allow borrowed pins. 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
a0511e6caa nrf/uart: make rts/cts optional. 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
e7e34cb8c2 nrf/gpio: add OptionalPin 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
df42c38492 nrf/uarte: update to new api 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
7b6086d19e nrf: add unborrow! macro 2021-03-29 00:58:58 +02:00
Dario Nieuwenhuis
a134fce122 nrf: nicer Peripherals api, add take() 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
d5ff1a0ae3 nrf: rename inner peripheral to peri for consistence 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
95218bf8d4 Rename GpioteInput -> PortInput 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
c0876187dd extras: move peripherals from nrf to extras 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
ec7309962a nrf/qspi: update to new api 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
16bb6fd6ac nrf: Specify connected bit in psel_bits 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
f36cbe5e0c nrf/spim: do not use PeripheralMutex 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
15eb46ec71 wip gpiote changels 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
ba7b3974bb nrf/gpiote: update to new gpio 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
3d3e770b8d nrf/gpio: add output drive config. 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
fcf6a63b5c nrf: add owned Peripherals struct, migrate gpio and spim 2021-03-29 00:58:57 +02:00
Dario Nieuwenhuis
456e04c79f Simplify spim macros 2021-03-18 21:59:35 +01:00
Dario Nieuwenhuis
b57489eb5d peripheralmutex: separate interrupt registration to own method. 2021-03-18 18:49:10 +01:00
Dario Nieuwenhuis
0cd19a58c3 Remove free() from PeripheralMutex and all nrf drivers. 2021-03-18 18:49:10 +01:00
Dario Nieuwenhuis
f248bb17ad Allow unused stuff in fmt.rs 2021-03-18 01:42:28 +01:00
Dario Nieuwenhuis
3de2d5c5bd Implement FullDuplex for nrf spim 2021-03-18 01:27:30 +01:00
Dario Nieuwenhuis
a9076636ac Do not export fmt macros.
This was introduced by accident by me struggling with the weird intra-crate macro importing system...
2021-03-17 22:50:27 +01:00
Dario Nieuwenhuis
6ed1a87138 Update features for latest nightly. 2021-03-17 02:48:16 +01:00
Thales Fragoso
15c3e78408 Move nRF's util into a separate crate 2021-03-07 20:15:40 -03:00
Timo Kröger
28b2365ef3 Update nrf-hal to v0.12.1
Use the `psel_bits()` method to reduce #[cfg] clutter
2021-03-05 09:25:46 +01:00
Dario Nieuwenhuis
d4f2c6cf00 Remove cargo namespaced-features 2021-03-02 21:15:12 +01:00
xoviat
9626aee7db Move traits to separate crate. 2021-03-02 00:32:23 +01:00
Dario Nieuwenhuis
67a6c4f469
Merge pull request #59 from akiles/interrupt_ext
move most interrupt methods to InterruptExt extension trait. Fixes #35
2021-03-01 00:56:20 +01:00
Dario Nieuwenhuis
45355f184a move most interrupt methods to InterruptExt extension trait. Fixes #35 2021-03-01 00:44:38 +01:00
Dario Nieuwenhuis
a30c705fd7 nrf/spim: support all chips 2021-03-01 00:36:30 +01:00
Dario Nieuwenhuis
255bf1aa6a nrf: add SPIM 2021-03-01 00:24:06 +01:00
Dario Nieuwenhuis
8a641d1312 Fix warnings. 2021-03-01 00:23:54 +01:00
Dario Nieuwenhuis
7433dc1039 Port qspi to PeripheralMutex 2021-02-28 22:05:37 +01:00
Dario Nieuwenhuis
962fb95ff0 Optimize PeripheralMutex code size 2021-02-28 22:03:45 +01:00
Dario Nieuwenhuis
da91779117 interrupt: Split set_handler context.
Since introducing the ctx pointer, the handler is now two words, so setting it can
race with the interrupt firing. On race it's possible for the new handler to be
alled with the old ctx pointer or viceversa.

Rather than documenting this, it's better to split the function in two to make it
obvious to the user that it's not atomic. The user can use a critical section, or
disable/enable the interrupt to avoid races if this is a concern.
2021-02-26 02:04:48 +01:00
Dario Nieuwenhuis
11be9170ec Cleanup interrupt package naming. Fixes #40
The `interrupt` package previously tried to be drop-in compatible with the
`interrupt` package from PACs. THis meant that there was both a PAC-style enum
value `UARTE0` and an embassy-style owned `UARTE0Interrupt` type. This made
things VERY confusing.

This drops compatibility with the PAC, improving the names for embassy interrupts.
2021-02-26 01:55:27 +01:00
Dario Nieuwenhuis
90476ef900 Fix some warnings. 2021-02-26 01:06:58 +01:00
Dario Nieuwenhuis
67c03e1a38
Merge pull request #47 from akiles/simpler-rtc
SImplify rtc overflow handling
2021-02-20 01:51:53 +01:00
Dario Nieuwenhuis
91aaea761e Use Relaxed atomics with fence instead of SeqCst 2021-02-20 01:43:10 +01:00
Dario Nieuwenhuis
03ddc949a0 PeripheralMutex should be Unpin 2021-02-20 00:27:24 +01:00
Dario Nieuwenhuis
406f3b7cbf rtc: use SeqCst for periods. 2021-02-15 01:23:15 +01:00
Dario Nieuwenhuis
9d5e2d3881 SImplify rtc overflow handling 2021-02-15 01:01:45 +01:00
Thales Fragoso
b69f72e055 Get rid of some warnings 2021-02-13 21:41:36 -03:00
Dario Nieuwenhuis
a7797a918d nrf/gpiote: new api: switch to owned structs, implement WaitForHigh/WaitForLow. 2021-02-04 23:56:17 +01:00
Dario Nieuwenhuis
aeaa34d7a1 Executor API V2.
- It's no longer possible to call run() reentrantly from within a task (soundness issue)
- it's now possible to spawn Send tasks across threads (SendSpawner, #37)
2021-02-02 05:20:41 +01:00
Dario Nieuwenhuis
6963b314a2 nrf/rtc: fix race when setting alarms too close to now. 2021-01-13 03:17:58 +01:00
Dario Nieuwenhuis
5229a1991c nrf/rtc: use interrupt handler context for instance ptr 2021-01-13 03:17:42 +01:00
Dario Nieuwenhuis
7b94e06306 nrf/buffered_uarte: fix stop not actually waiting for stop 2021-01-11 11:24:34 +01:00
Dario Nieuwenhuis
41160c0d8d nrf/buffered_uarte: add set_baudrate 2021-01-11 10:40:37 +01:00
Dario Nieuwenhuis
2616467377 nrf/buffered_uarte: stop on drop, add free() 2021-01-11 10:39:59 +01:00
Dario Nieuwenhuis
e18d71dedc Fix build on nrf52832 2021-01-07 00:50:40 +01:00
Dario Nieuwenhuis
5b10ac9cac Add PPI+TIMER to buffered_uarte to prevent IRQ storm 2021-01-06 23:36:46 +01:00
Dario Nieuwenhuis
deb3c93892 Simpliify PeripheralMutex a bit. 2021-01-06 22:48:54 +01:00
Dario Nieuwenhuis
77bdb5428e buffered_uarte naming cleanup 2021-01-06 20:21:03 +01:00
Dario Nieuwenhuis
9bb4c97dc2
Merge pull request #14 from timokroeger/uarte-power-optimization
UARTE power optimization and improvements
2021-01-05 22:10:52 +01:00
Dario Nieuwenhuis
607e67f51a Cleanup BufferedUarte 2021-01-05 21:14:04 +01:00
Dario Nieuwenhuis
3a4dbfa52e Massicely simplify peripheral abstraction 2021-01-05 01:57:05 +01:00
Timo Kröger
0631623b51 uarte: Low power wait for RX drop 2021-01-04 22:55:40 +01:00
Timo Kröger
93780fa31d uarte: Wait for the peripheral to be disabled
Prevents a panic in the case of:
1. Abort a receive future
2. Free Uarte::free()
3. Uarte::new()
->  panicked at 'assertion failed: uarte.enable.read().enable().is_disabled()'
2021-01-04 22:55:40 +01:00
Timo Kröger
9b1f7b8a17 uarte: Enable peripheral with first poll
This fixes a lockup when a future is dropped before it was polled.
2021-01-04 22:55:40 +01:00
Timo Kröger
85ec9dd16f uarte: Be on safe side with potentially racy code
The PS does not specify how many cycles it takes for a STARTXX task to
generate a XXSTARTED event. I think it is instantaneous but let’s be on
the safe side for the following sequence:
1. poll() starttx
2. drop() txstarted not yet set, but future gets dropped
3. txstarted set by hardware, peripheral enabled after it was dropped
2021-01-04 22:55:40 +01:00
Timo Kröger
a3b3305b8e uarte: Only stop TX forcefully when a transmissions is running
This comes with insignificant power consumption improvements but makes
the code of the RX and TX case symmetric.
2021-01-04 22:55:40 +01:00
Timo Kröger
a7c03e4cb6 uarte: Only stop RX forcefully when a reception is running
The STOPRX task always triggers a timeout of ~55bit times until the
RXTO event is generated. Before we disabled the receiver only after
the timeout.
With this change the receiver is stopped right after reception has ended
because the DMA buffer is full.
For forced RX aborts like `stop()` or on drop still need to wait for the
RXTO event before disabling the receiver.
2021-01-04 22:55:40 +01:00
Timo Kröger
9f28c7ab8d uarte: Do not spin when stopping a receive future
Spinning on drop() is still required when the future has not been
stopped so that DMA finishes before the buffer is released.
2021-01-04 22:55:40 +01:00
Dario Nieuwenhuis
9e88718fbd Add "context" pointer to owned interrupt handlers. 2021-01-04 22:25:39 +01:00
Dario Nieuwenhuis
39ca8b8ded Fix build on non-nrf52840 2021-01-03 22:30:47 +01:00
Dario Nieuwenhuis
ace4f40f80 Introduce "peripheral" abstraction to share state between main and interrupt. 2021-01-03 01:40:40 +01:00
Dario Nieuwenhuis
4ce51795f2 use hal::Pins for BufferedUarte 2021-01-02 20:31:50 +01:00
Dario Nieuwenhuis
0ab88ea279 Add Uart trait, implement it for nrf. 2021-01-02 19:59:37 +01:00
Dario Nieuwenhuis
3c7e7220b3 Don't use embedded_dma in nrf uarte. 2021-01-02 19:14:54 +01:00
Dario Nieuwenhuis
4783222f67 Rename WakerStore -> WakerRegistration. 2021-01-01 22:30:11 +01:00
Timo Kröger
6695bf0f21 Low power UART driver 2020-12-30 19:24:12 +01:00
Dario Nieuwenhuis
7dc81faa4e Declare irqs for each nrf chip 2020-12-29 15:20:42 +01:00
Dario Nieuwenhuis
af5454fbfe Update drivers to owned irqs. 2020-12-29 01:53:17 +01:00
Dario Nieuwenhuis
4b8d8ba87e Update RTC for owned irqs 2020-12-29 01:05:28 +01:00
Dario Nieuwenhuis
0750234fbe WIP owned irqs 2020-12-29 00:05:52 +01:00
Dario Nieuwenhuis
267ec334ac Rename Uarte -> BufferedUarte 2020-12-28 23:57:50 +01:00
Dario Nieuwenhuis
1aae27270e Better fmt macros. 2020-12-13 21:17:58 +01:00
Dario Nieuwenhuis
ca2ff632ba Fix possibly ambiguous macro 2020-12-01 20:00:55 +01:00
Dario Nieuwenhuis
6f76c0ebcc Add support for log+defmt again, but better. 2020-12-01 17:46:56 +01:00
Dario Nieuwenhuis
78135a81d9 Remove anyfmt 2020-11-27 18:42:59 +01:00
Dario Nieuwenhuis
2e062f5627 gpiote: change port api to directly return futures. 2020-11-09 01:04:34 +01:00
Dario Nieuwenhuis
61b1d4e188 Fix build for nrfs with 32 gpios 2020-11-08 19:05:34 +01:00
Dario Nieuwenhuis
e539cd32ca Fix logging with anyfmt/log 2020-11-08 19:00:23 +01:00
Dario Nieuwenhuis
fc0fe842ee Add support for GPIOTE Port event. 2020-11-08 18:59:31 +01:00
Dario Nieuwenhuis
def225b982 gpiote: better naming 2020-11-08 17:38:45 +01:00
Dario Nieuwenhuis
0a3590566d Fix ambiguous assert 2020-11-01 17:56:29 +01:00
Dario Nieuwenhuis
5e8608c7a5 Make defmt optional with new anyfmt crate 2020-11-01 17:17:24 +01:00
Dario Nieuwenhuis
0643095695 Fix build with all nrf chip models 2020-10-31 23:03:09 +01:00
Dario Nieuwenhuis
9dea5035b9 Remove unused 2020-10-31 22:36:02 +01:00
Dario Nieuwenhuis
ec4b95579d gpiote: take owned pin but add function to borrow it. 2020-10-19 21:25:54 +02:00
Dario Nieuwenhuis
33dce24e8a Add gpiote output channel. 2020-09-29 19:18:52 +02:00
Dario Nieuwenhuis
c81d626254 gpiote: take borrow instead of owned pin.
This makes it possible to read the pin while the channel is created.
2020-09-29 04:17:32 +02:00
Dario Nieuwenhuis
37d2b440ff Fix rtc using multiple alarms at the same time. 2020-09-26 00:35:25 +02:00
Dario Nieuwenhuis
19a89b5c14 Add Clock trait 2020-09-25 23:38:42 +02:00
Dario Nieuwenhuis
cf1d604749 Add support for multi alarm to RTC. 2020-09-25 23:25:49 +02:00
Dario Nieuwenhuis
4333105341 Add Executor with timer queue, Timer, Instant, Duration, Alarm. 2020-09-25 03:25:06 +02:00
Dario Nieuwenhuis
05ca563e7d Add clock::Monotonic trait. 2020-09-24 23:26:24 +02:00
Dario Nieuwenhuis
82e5e3c45f rtc: Add alarm callback. 2020-09-24 22:41:52 +02:00
Dario Nieuwenhuis
3b39ab07e5 Add 64-bit rtc driver with alarm support. 2020-09-24 19:59:20 +02:00
Dario Nieuwenhuis
4e4241bf90 remove nrf prefix in features, for consistency with nrf-hal 2020-09-24 19:56:47 +02:00
Dario Nieuwenhuis
f9e2cef7f2 Add GPIOTE async hal. 2020-09-23 00:32:49 +02:00
Dario Nieuwenhuis
9a57deef9b First commit 2020-09-22 18:03:43 +02:00