#![no_std]
#![doc = include_str!("../README.md")]
pub use ms56xx::{
Error, I2cInterface, Measurement, OversamplingStandard as Oversampling, SpiInterface,
};
use ms56xx::{Ms56xx, Ms5611 as Ms5611Variant};
pub struct Ms5611<INTERFACE> {
inner: Ms56xx<INTERFACE, Ms5611Variant>,
}
impl<I2C> Ms5611<I2cInterface<I2C>> {
pub fn new_i2c(i2c: I2C, csb_high: bool) -> Self {
Self {
inner: Ms56xx::new_i2c(i2c, csb_high),
}
}
pub fn new_i2c_with_address(i2c: I2C, address: u8) -> Self {
Self {
inner: Ms56xx::new_i2c_with_address(i2c, address),
}
}
pub fn address(&self) -> u8 {
self.inner.address()
}
pub fn destroy(self) -> I2C {
self.inner.destroy()
}
}
impl<SPI> Ms5611<SpiInterface<SPI>> {
pub fn new_spi(spi: SPI) -> Self {
Self {
inner: Ms56xx::new_spi(spi),
}
}
pub fn destroy(self) -> SPI {
self.inner.destroy()
}
}
impl<INTERFACE> Ms5611<INTERFACE> {
pub fn is_initialized(&self) -> bool {
self.inner.is_initialized()
}
}
impl<I2C: embedded_hal_async::i2c::I2c> Ms5611<I2cInterface<I2C>> {
pub async fn reset(
&mut self,
delay: &mut impl embedded_hal_async::delay::DelayNs,
) -> Result<(), I2C::Error> {
self.inner.reset(delay).await
}
pub async fn init(
&mut self,
delay: &mut impl embedded_hal_async::delay::DelayNs,
) -> Result<(), Error<I2C::Error>> {
self.inner.init(delay).await
}
pub async fn measure(
&mut self,
osr: Oversampling,
delay: &mut impl embedded_hal_async::delay::DelayNs,
) -> Result<Measurement, Error<I2C::Error>> {
self.inner.measure(osr, delay).await
}
}
impl<I2C: embedded_hal::i2c::I2c> Ms5611<I2cInterface<I2C>> {
pub fn reset_blocking(
&mut self,
delay: &mut impl embedded_hal::delay::DelayNs,
) -> Result<(), I2C::Error> {
self.inner.reset_blocking(delay)
}
pub fn init_blocking(
&mut self,
delay: &mut impl embedded_hal::delay::DelayNs,
) -> Result<(), Error<I2C::Error>> {
self.inner.init_blocking(delay)
}
pub fn measure_blocking(
&mut self,
osr: Oversampling,
delay: &mut impl embedded_hal::delay::DelayNs,
) -> Result<Measurement, Error<I2C::Error>> {
self.inner.measure_blocking(osr, delay)
}
}
impl<SPI: embedded_hal_async::spi::SpiDevice> Ms5611<SpiInterface<SPI>> {
pub async fn reset(
&mut self,
delay: &mut impl embedded_hal_async::delay::DelayNs,
) -> Result<(), SPI::Error> {
self.inner.reset(delay).await
}
pub async fn init(
&mut self,
delay: &mut impl embedded_hal_async::delay::DelayNs,
) -> Result<(), Error<SPI::Error>> {
self.inner.init(delay).await
}
pub async fn measure(
&mut self,
osr: Oversampling,
delay: &mut impl embedded_hal_async::delay::DelayNs,
) -> Result<Measurement, Error<SPI::Error>> {
self.inner.measure(osr, delay).await
}
}
impl<SPI: embedded_hal::spi::SpiDevice> Ms5611<SpiInterface<SPI>> {
pub fn reset_blocking(
&mut self,
delay: &mut impl embedded_hal::delay::DelayNs,
) -> Result<(), SPI::Error> {
self.inner.reset_blocking(delay)
}
pub fn init_blocking(
&mut self,
delay: &mut impl embedded_hal::delay::DelayNs,
) -> Result<(), Error<SPI::Error>> {
self.inner.init_blocking(delay)
}
pub fn measure_blocking(
&mut self,
osr: Oversampling,
delay: &mut impl embedded_hal::delay::DelayNs,
) -> Result<Measurement, Error<SPI::Error>> {
self.inner.measure_blocking(osr, delay)
}
}