Skip to content

Commit d9d3e02

Browse files
committed
example and fuzz updated
Signed-off-by: JadKHaddad <[email protected]>
1 parent 0e9b883 commit d9d3e02

File tree

9 files changed

+117
-19
lines changed

9 files changed

+117
-19
lines changed

bmp180/fuzz/Cargo.lock

+81
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bmp180/fuzz/fuzz_targets/init_update.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#![no_main]
22

33
use bmp180::{
4+
blocking::UninitBMP180,
45
fuzz::{FuzzDelay, FuzzI2C},
5-
BlockingBMP180, BlockingInitBMP180, UninitBMP180,
66
};
77

88
use libfuzzer_sys::fuzz_target;

bmp180/src/error.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
/// Error type for BMP180 devices.
1+
/// Error type for `BMP180` devices.
2+
#[derive(Debug)]
23
pub enum BMP180Error<I2CError> {
34
/// I2C error.
45
I2C(I2CError),
56
/// Invalid device ID.
67
InvalidId(u8),
7-
/// Aretmetic error.
8+
/// Arithmetic error.
89
///
910
/// Accurs on:
10-
/// - Deviding by zero.
11-
/// - Overflow.
12-
/// - Underflow.
11+
/// - Deviding by zero
12+
/// - Overflow
13+
/// - Underflow
1314
Arithmetic,
1415
}

bmp180/src/fuzz.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use core::convert::Infallible;
44

5-
use crate::device::{id::Id, register::Register};
5+
use crate::{id::Id, register::Register};
66

77
/// Fuzzing delay.
88
///

bmp180/src/id.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//! Valid BMP180 device ID.
1+
//! Valid `BMP180` device ID.
22
3-
/// Valid BMP180 device ID.
3+
/// Valid `BMP180` device ID.
44
#[repr(u8)]
55
pub enum Id {
66
Valid = 0x55,

bmp180/src/lib.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,25 @@
1616

1717
mod address;
1818
mod calibration;
19-
pub mod device;
19+
mod device;
2020
mod error;
2121
pub(crate) mod id;
2222
mod mode;
2323
mod register;
2424

25+
#[cfg(feature = "fuzz")]
26+
pub mod fuzz;
27+
2528
pub use crate::address::Address;
2629
pub use crate::calibration::Calibration;
2730
pub use crate::error::BMP180Error;
2831
pub use crate::mode::Mode;
2932

30-
#[cfg(feature = "fuzz")]
31-
pub mod fuzz;
33+
#[cfg(feature = "async")]
34+
pub use crate::device::asynch;
35+
36+
#[cfg(feature = "blocking")]
37+
pub use crate::device::blocking;
3238

3339
/// Our custom `try!` macro aka `?`, to get rid of [`core::convert::From`]/[`core::convert::Into`] used by the `?` operator.
3440
macro_rules! tri {

bmp180/src/register.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//! Register addresses for the BMP180 device.
1+
//! Register addresses for the `BMP180` device.
22
3-
/// Register addresses for the BMP180 device.
3+
/// Register addresses for the `BMP180` device.
44
#[repr(u8)]
55
pub enum Register {
66
ChipId = 0xD0,

examples/esp32/Cargo.lock

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/esp32/src/main.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
#![no_main]
33
#![feature(type_alias_impl_trait)]
44

5-
use bmp180::{AsyncBMP180, AsyncInitBMP180, BaseBMP180, Mode, UninitBMP180};
5+
use bmp180::{asynch::UninitBMP180, Mode};
66
use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice;
77
use embassy_executor::Spawner;
8-
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
9-
use embassy_sync::mutex::Mutex;
10-
use embassy_time::{Duration, Timer};
8+
use embassy_sync::{blocking_mutex::raw::NoopRawMutex, mutex::Mutex};
9+
use embassy_time::{Delay, Duration, Timer};
1110
use esp_backtrace as _;
1211
use esp_hal::{
1312
clock::ClockControl,
@@ -49,7 +48,7 @@ async fn main(_spawner: Spawner) {
4948

5049
embassy::init(&clocks, timg0);
5150

52-
let mut bmp180 = UninitBMP180::builder(i2c_dev1, embassy_time::Delay {})
51+
let mut bmp180 = UninitBMP180::builder(i2c_dev1, Delay {})
5352
.mode(Mode::UltraHighResolution)
5453
.build()
5554
.initialize()

0 commit comments

Comments
 (0)