mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-11 04:51:31 +11:00
Implement embedded-hal 1.0.0-alpha.8 traits (#366)
* Implement embedded-hal 1.0.0-alpha.8 traits * Add comment about missing SPI traits
This commit is contained in:
parent
f7cfeec0d7
commit
99dfeaf6f2
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Update embedded-hal alpha support to version 1.0.0-alpha.8
|
||||||
|
|
||||||
## [0.5.0] - 2022-06-13
|
## [0.5.0] - 2022-06-13
|
||||||
|
|
||||||
### MSRV
|
### MSRV
|
||||||
|
|
|
@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0"
|
||||||
cortex-m = "0.7.2"
|
cortex-m = "0.7.2"
|
||||||
cortex-m-rt = ">=0.6.15,<0.8"
|
cortex-m-rt = ">=0.6.15,<0.8"
|
||||||
embedded-hal = { version = "0.2.5", features = ["unproven"] }
|
embedded-hal = { version = "0.2.5", features = ["unproven"] }
|
||||||
eh1_0_alpha = { version = "=1.0.0-alpha.7", package="embedded-hal", optional=true }
|
eh1_0_alpha = { version = "=1.0.0-alpha.8", package="embedded-hal", optional=true }
|
||||||
embedded-time = "0.12.0"
|
embedded-time = "0.12.0"
|
||||||
itertools = { version = "0.10.1", default-features = false }
|
itertools = { version = "0.10.1", default-features = false }
|
||||||
nb = "1.0"
|
nb = "1.0"
|
||||||
|
|
|
@ -102,6 +102,8 @@ will be breaking changes even in minor versions of rp2040-hal.
|
||||||
Support for embedded-hal 1.0(-alpha) exists in parallel to support for
|
Support for embedded-hal 1.0(-alpha) exists in parallel to support for
|
||||||
embedded-hal 0.2: Traits of both versions are implemented and can be used
|
embedded-hal 0.2: Traits of both versions are implemented and can be used
|
||||||
at the same time.
|
at the same time.
|
||||||
|
The new blocking [SPI traits](https://docs.rs/embedded-hal/1.0.0-alpha.8/embedded_hal/spi/blocking/index.html)
|
||||||
|
are not yet implemented.
|
||||||
|
|
||||||
<!-- CONTRIBUTING -->
|
<!-- CONTRIBUTING -->
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
|
@ -103,15 +103,6 @@ macro_rules! channel {
|
||||||
$channel
|
$channel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1_0_alpha")]
|
|
||||||
impl eh1_0_alpha::adc::nb::Channel<Adc> for Pin<$pin, FloatingInput> {
|
|
||||||
type ID = u8; // ADC channels are identified numerically
|
|
||||||
|
|
||||||
fn channel(&self) -> u8 {
|
|
||||||
$channel
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,15 +124,6 @@ impl Channel<Adc> for TempSense {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1_0_alpha")]
|
|
||||||
impl eh1_0_alpha::adc::nb::Channel<Adc> for TempSense {
|
|
||||||
type ID = u8; // ADC channels are identified numerically
|
|
||||||
|
|
||||||
fn channel(&self) -> u8 {
|
|
||||||
TEMPERATURE_SENSOR_CHANNEL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<WORD, PIN> OneShot<Adc, WORD, PIN> for Adc
|
impl<WORD, PIN> OneShot<Adc, WORD, PIN> for Adc
|
||||||
where
|
where
|
||||||
WORD: From<u16>,
|
WORD: From<u16>,
|
||||||
|
@ -171,34 +153,3 @@ where
|
||||||
Ok(self.device.result.read().result().bits().into())
|
Ok(self.device.result.read().result().bits().into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1_0_alpha")]
|
|
||||||
impl<WORD, PIN> eh1_0_alpha::adc::nb::OneShot<Adc, WORD, PIN> for Adc
|
|
||||||
where
|
|
||||||
WORD: From<u16>,
|
|
||||||
PIN: eh1_0_alpha::adc::nb::Channel<Adc, ID = u8>,
|
|
||||||
{
|
|
||||||
type Error = ();
|
|
||||||
|
|
||||||
fn read(&mut self, pin: &mut PIN) -> nb::Result<WORD, Self::Error> {
|
|
||||||
let chan = PIN::channel(pin);
|
|
||||||
|
|
||||||
if chan == 4 {
|
|
||||||
self.device.cs.modify(|_, w| w.ts_en().set_bit())
|
|
||||||
}
|
|
||||||
|
|
||||||
while !self.device.cs.read().ready().bit_is_set() {
|
|
||||||
cortex_m::asm::nop();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.device
|
|
||||||
.cs
|
|
||||||
.modify(|_, w| unsafe { w.ainsel().bits(chan).start_once().set_bit() });
|
|
||||||
|
|
||||||
while !self.device.cs.read().ready().bit_is_set() {
|
|
||||||
cortex_m::asm::nop();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(self.device.result.read().result().bits().into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue