Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async API #635

Open
wants to merge 84 commits into
base: master
Choose a base branch
from
Open

Async API #635

wants to merge 84 commits into from

Conversation

jbeaurivage
Copy link
Contributor

@jbeaurivage jbeaurivage commented Oct 24, 2022

Provide APIs to use some peripherals using async/await.

HAL features

One new feature is added to the HAL: async

MSRV

This PR bumps the HAL MSRV to rustc 1.75. However everything compiles on stable.

Peripherals implemented

  • Timer/Counter (TC)
  • I2C
  • UART
  • SPI
  • DMAC
  • GPIO interrupts (EIC)

Todo

  • Document everything
  • Find best API for interrupt ownership
  • Convert to new peripheral-feature system, especially brand new modules

Examples

Some examples are provided for feather_m0 (and a few for metro_m4). Some more examples will be added in time, perhaps in a follow-up PR.

@jbeaurivage jbeaurivage marked this pull request as ready for review January 8, 2024 22:08
* Working async timer driver implementation for thumbv6m and thumbv7em targets

#[inline]
fn buffer_len(&self) -> usize {
1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the SERCOM peripherals expect all data to be read/written to the same register address. In the case of a transmission, it then may add it to an internal buffer, after which the data is transmitted (the reverse happens for receive transactions). Therefore the DMA transfer must direct all the incoming/outgoing data to the same memory address, regardless of the transaction length.

@sajattack
Copy link
Member

I'm sorry this sat so long. I'm pretty sure my feather m0 board is busted after I wired up a battery to it backwards. Would you mind porting more of the examples to metro m4 so I can get a better feel for this?

@jbeaurivage
Copy link
Contributor Author

I'm sorry this sat so long. I'm pretty sure my feather m0 board is busted after I wired up a battery to it backwards. Would you mind porting more of the examples to metro m4 so I can get a better feel for this?

Of course! The feather_m0 examples are ported to metro_m4. Unfortunately they aren't yet using clock::v2 as I'm not super sure how to use it correctly. One example I think will definitely need testing is async_eic, I'm not 100% sure about it yet, even though it works well on thumbv6 targets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants