Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Q: How to use Wait::wait_for_low and avoid the race condition between interrupt setup and pin triggering?

Đang mở
#653 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tài liệu
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
embedded-iot

Hướng nghiên cứu

Start with embedded-hal-async/src/digital.rs at the Wait trait and compare the esp-hal GPIO implementation linked in the report. Determine whether the trait needs usage guidance or an API change to make interrupt setup safe before triggering activity, then document or specify the intended sequence and its completion criteria.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hi folks,

I am trying to detect a brief pulse using embedded-hal-async GPIO Wait trait. The methods like wait_for_low are perfect for that in general (https://github.com/rust-embedded/embedded-hal/blob/master/embedded-hal-async/src/digital.rs#L34)

However most of the implementations I have seen configure the interrupt within the wait_for_low method which means it must first be polled at least once (but sometimes more) before the interrupt is set up properly. See for example how the esp waits for the setup to be possible here https://github.com/esp-rs/esp-hal/blob/87d501766f178a2dd812c382ca257d268ee266ad/esp-hal/src/gpio/mod.rs#L2242

Now, I have a device where the pulse can disappear on its own and I need to detect it reliably. I have custom code that first sets up the interrupt and only then triggers the behavior. This works, but I would like to rewrite my custom code to adhere to the embedded-hal-async traits.

Do you have any idea about how to use the wait_for_low in this way? First set-up the interrupts, then do something outside to trigger the activity and then wait for the interrupt to happen?

The code I have right know looks roughly like this:

let w = WaitForPin::listen(gpio, pin, LOW);
device.start()
w.await;

TLDR: How to use Wait::wait_for_low and avoid the race condition between interrupt setup and pin triggering?

Ngôn ngữ chính
Rust
Star
2.7k
Fork
283
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rust-embedded/embedded-hal

Tất cả issue của rust-embedded/embedded-hal

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.