Skip to content

Use Timer instead of Delay #3

@Arkaleks

Description

@Arkaleks

Current implementation of this driver takes ownership of a Delay in order to block get_compensated_sample() and alike operations. While this is fine as a very simple solution, not all implementations of embedded_hal provide multiple Delay object, e.g. atsamd implementation only provides one Delay which is using Systick as delay provider.

Instead of replacing the API to borrow a Delay whenever an operation need it, the API could be changed to be non-blocking by using a Timer:

// Old
pub fn get_sample(&mut self, osr: Oversampling) -> Result<Sample, E> {}

// New
pub fn get_sample(&mut self, osr: Oversampling) -> nb::Result<Sample, Error<SPI>>{}

Where get_sample``returns nb::WouldBlock ` as long as a conversion is ongoing, allowing user's code to do other operation in the mean time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions