Commit graph

3112 commits

Author SHA1 Message Date
Jeremy Fitzhardinge
4fd831e4a8 rp async i2c: raise the tx_empty threshold
Assert "tx_empty" interrupt a little early so there's time to wake up
and start refilling the fifo before it drains. This avoids stalling the
i2c bus if the tx fifo completely drains.
2022-10-03 18:50:03 -07:00
Jeremy Fitzhardinge
cae8499179 rp i2c: clean up tx_abrt handling
Make sure we always wait for the stop bit if there's a reason to -
either because we sent one, or because there was a hardware tx abort.
2022-10-03 01:18:26 -07:00
Jeremy Fitzhardinge
e8bb8faa23 rp i2c: allow blocking ops on async contexts 2022-10-02 15:09:14 -07:00
Jeremy Fitzhardinge
09afece93d make I2c::write_async take an iterator
There's no other iterator async API right now.
2022-10-01 19:28:27 -07:00
Jeremy Fitzhardinge
1ee4bb22de embassy-rp i2c: async (non-blocking) example
Simple example exercising an mcp23017 GPIO expander, configured on
RP2040 GPIOs 14+15 (i2c1) with 8 inputs and 8 outputs. Input bit 0
controls whether to display a mcp23017 register dump.
2022-10-01 13:43:37 -07:00
Jeremy Fitzhardinge
5e2c52ee5b embassy-rp: async i2c implementation
This is an interrupt-driven async i2c master implementation. It makes as
best use of the RP2040's i2c block's fifos as possible to minimize
interrupts.

It implements embedded_hal_async::i2c for easy interop.
WIP async impl
2022-10-01 13:43:37 -07:00
Jeremy Fitzhardinge
72b645b0c9 rp i2c: make blocking only for Mode=Blocking 2022-10-01 13:26:13 -07:00
Jeremy Fitzhardinge
8d38eacae4 rp i2c: remove vestiges of DMA 2022-10-01 13:26:13 -07:00
Jeremy Fitzhardinge
90d392205f embassy-rp: inline I2c::regs
It just returns a literal constant, so there's no reason not to always inline it.
2022-10-01 13:26:13 -07:00
bors[bot]
aabc02506b
Merge #992
992: (embassy-stm32): remove flash lock/unlock public API from stm32 flash r=lulf a=MathiasKoch

Instead, perform the unlocking and locking automatically on erase and write operations.

This makes the `embedded-storage` abstraction actually useable in libraries, while still keeping the flash peripheral locked the majority of the time.

Co-authored-by: Mathias <mk@blackbird.online>
2022-09-30 11:32:27 +00:00
bors[bot]
99284b8304
Merge #981
981: (embassy-stm32): add E-H1 uart blocking & nb implementation r=MathiasKoch a=MathiasKoch



Co-authored-by: Mathias <mk@blackbird.online>
2022-09-30 04:14:52 +00:00
Mathias
a283c47557 Implement embedded-hal-nb for uart 2022-09-30 06:04:19 +02:00
Mathias
a7fdeac560 Remove flash lock/unlock public API from stm32 flash, and perform the unlocking and locking automatically on erase and write operations 2022-09-30 06:00:46 +02:00
Mathias
88a3c360e8 Merge branch 'master' of https://github.com/embassy-rs/embassy into embassy-stm32/uart-eh1 2022-09-30 05:23:59 +02:00
bors[bot]
1d6f5493e7
Merge #991
991: usb: remove all "Direction as u8" casts. r=Dirbaio a=Dirbaio

Alternative fix for #989 , see comment there for rationale.

bors r+

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-09-29 13:53:22 +00:00
Dario Nieuwenhuis
dab1762709 usb: remove all "Direction as u8" casts. 2022-09-29 15:52:23 +02:00
bors[bot]
ebf5a92ab2
Merge #990
990: Small pubsub improvements r=Dirbaio a=diondokter

- Futures in pub & sub are now awaited instead of returned
- Added functions for reading how many messages are available

This helps people get better compiler diagnostics. For example, I forgot to call await on a future and the compiler didn't complain.
This also helps with making some decisions based on the state of the channels.

Co-authored-by: Dion Dokter <dion@tweedegolf.com>
2022-09-29 13:28:56 +00:00
Dion Dokter
874384826d Went back to named futures but now with must_use 2022-09-29 15:15:10 +02:00
Dion Dokter
f4ebc36b63 Futures in pub & sub are now awaited instead of returned for better user compiler diagnostics.
Added functions for reading how many messages are available
2022-09-29 14:24:42 +02:00
Mathias
a77e2c3512 Merge branch 'master' of https://github.com/embassy-rs/embassy into embassy-stm32/uart-eh1 2022-09-29 12:58:01 +02:00
bors[bot]
8b9f4ad259
Merge #988
988: Update embedded-hal versions and explicitly pin r=lulf a=lulf

Pinning to ensure CI don't accidentally break.

Co-authored-by: Ulf Lilleengen <lulf@redhat.com>
2022-09-29 09:29:33 +00:00
Ulf Lilleengen
72c2e985bb Update embedded-hal versions and explicitly pin 2022-09-29 11:27:46 +02:00
Mathias
dc90006982 Remove code duplication on nb_read 2022-09-29 07:58:11 +02:00
bors[bot]
77ece3f903
Merge #983
983: Remove subghz static lifetime requirement r=lulf a=lulf



Co-authored-by: Ulf Lilleengen <lulf@redhat.com>
2022-09-28 09:33:50 +00:00
Ulf Lilleengen
d7f7614b22 Remove subghz static lifetime requirement 2022-09-28 11:32:11 +02:00
Mathias
823bd714fb Add E-H1 uart blocking & nb implementation 2022-09-28 05:19:43 +02:00
bors[bot]
9bb43ffe9a
Merge #914
914: (embassy-rp): Add I2C master implementation r=Dirbaio a=MathiasKoch

This PR adds both blocking and DMA based async implementations of I2C master.

Both E-H 0.2 & E-H 1.0 abstractions are implemented as well.

### Questions & concerns:
- Do we need an I2C interrupt handler (for transfer done, abort & error handling?) (async only)
- Do we need to add some automatic attempt at unblocking an I2C bus in case of failures (see ref: 7ebfd553f3/src/i2c_dma.c (L116-L142))
- Should I add `vectored_{read, write}` implementations?

Co-authored-by: Mathias <mk@blackbird.online>
Co-authored-by: Mathias Koch <mk@blackbird.online>
2022-09-27 20:09:53 +00:00
Mathias
bf1da0497c Allow unused fields temporarily in i2c 2022-09-27 22:08:49 +02:00
Mathias
44c46e3c93 Move async i2c implementation to new PR, to merge working blocking implementation faster 2022-09-27 22:08:49 +02:00
Mathias Koch
b0d91e9f31 Apply suggestions from code review
Co-authored-by: Jacob Gonzalez <jacobgonzalez5252@gmail.com>
2022-09-27 22:08:49 +02:00
Mathias
53c34ccc39 Add async API for I2C 2022-09-27 22:08:49 +02:00
Mathias
be68d8ebb7 Add further i2c error types 2022-09-27 22:08:49 +02:00
Mathias
603513e76e Fix blocking I2C 2022-09-27 22:08:49 +02:00
Mathias
bcd3ab4ba1 Add blocking read & write for I2C 2022-09-27 22:08:49 +02:00
Mathias
820e6462b6 Add preliminary I2C implementation for RP2040 2022-09-27 22:08:49 +02:00
bors[bot]
5c882cf4fa
Merge #979
979: usb: make HALs depend only on embassy-usb-driver. r=Dirbaio a=Dirbaio

Follow up to #972 

bors r+

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-09-27 11:17:14 +00:00
Dario Nieuwenhuis
17d8d11f73 usb: make HALs depend only on embassy-usb-driver. 2022-09-27 13:16:49 +02:00
bors[bot]
82d4360756
Merge #934
934: (embassy-rp): Add Buffered UART implementation r=MathiasKoch a=MathiasKoch

### Questions & concerns: 
- ~~Would it make sense to add `RxBufferedUart` and `TxBufferedUart`, for cases where you would want to only buffer one way?~~
- ~~Do I need to be monitoring more interrupt flags than `Receive` & `Receive timeout`?~~

This PR adds working `BufferedUart` implementation, along with `RxBufferedUart` and `TxBufferedUart`. The implementation leaves room for improvement with respect to performance, as it still does not utilize DMA nor the internal UART buffers.

Co-authored-by: Mathias <mk@blackbird.online>
Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-09-27 06:00:33 +00:00
Mathias
e129a97d48 Fix bufferedUart read and write tests 2022-09-27 07:45:10 +02:00
Mathias
93354b812c Extend buffered-uart test to transmit 32 bytes 2022-09-27 05:54:31 +02:00
Mathias
65907204d6 Rename from {Rx,Tx}BufferedUart to BufferedUart{Rx,Tx} to be compliant with stm32 and nrf implementations 2022-09-27 05:51:31 +02:00
Mathias
cd539ba3a0 Rebase 2022-09-27 05:51:14 +02:00
bors[bot]
86fd480672
Merge #973
973: Rework STM32 BufferedUart internals so we can split into Rx and Tx like embassy-nrf r=lulf a=guillaume-michel

Context:
On STM32, BufferedUart is not splittable into Rx and Tx part like the non buffered version. On embassy-nrf, a RefCell is used to make BufferedUarte splittable.

Description:
This PR add the possibility to split BufferedUart into Rx and Tx without adding breaking changes.

Hope somebody find it useful

Co-authored-by: Guillaume MICHEL <guillaume@squaremind.io>
2022-09-26 19:30:15 +00:00
bors[bot]
de0070948c
Merge #976
976: rp: enable time-driver in Cargo.toml instead of ci.sh r=Dirbaio a=Dirbaio

bors r+

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2022-09-26 19:05:39 +00:00
bors[bot]
7bbb4c22a1
Merge #977
977: Use firmware writer in stm32{f7, h7} example app r=lulf a=lulf

The new FirmwareWriter is useful in particular for these architectures due to the large erase sector size.

Co-authored-by: Ulf Lilleengen <ulf.lilleengen@gmail.com>
2022-09-26 18:47:05 +00:00
Ulf Lilleengen
5bf6564e95 Use firmware writer in stm32{f7, h7} example app
The new FirmwareWriter is useful in particular for these architectures
due to the large erase sector size.
2022-09-26 20:36:57 +02:00
Dario Nieuwenhuis
c863acd24f rp: set correct teleprobe target for rpi-pico tests. 2022-09-26 20:36:06 +02:00
Mathias
f76444bdc4 Add HIL test for bufferedUart 2022-09-26 20:34:55 +02:00
Mathias
b3dfd06dd6 Remove code-duplication in async bufferedUart implementations 2022-09-26 20:34:55 +02:00
Mathias
1db9e464ff Enable embedded-io on nightly 2022-09-26 20:34:55 +02:00