Skip to content

Commit

Permalink
Tidied up source formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhodapp authored and calebbourg committed Oct 28, 2022
1 parent 65894c2 commit 972d40b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion esp32-wroom-rp/src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Default for EspControlPins<(), (), (), ()> {
cs: (),
gpio0: (),
resetn: (),
ack: ()
ack: (),
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions esp32-wroom-rp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub mod wifi;
pub mod protocol;
mod spi;

use protocol::{ProtocolInterface, ProtocolError};
use protocol::{ProtocolError, ProtocolInterface};

use defmt::{write, Format, Formatter};
use embedded_hal::blocking::delay::DelayMs;
Expand All @@ -111,7 +111,11 @@ impl Format for Error {
fn format(&self, fmt: Formatter) {
match self {
Error::Bus => write!(fmt, "Bus error"),
Error::Protocol(e) => write!(fmt, "Communication protocol error with ESP32 WiFi target: {}", e),
Error::Protocol(e) => write!(
fmt,
"Communication protocol error with ESP32 WiFi target: {}",
e
),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion esp32-wroom-rp/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub enum ProtocolError {
CommunicationTimeout,
InvalidCommand,
InvalidNumberOfParameters,
TooManyParameters
TooManyParameters,
}

impl Format for ProtocolError {
Expand Down
18 changes: 10 additions & 8 deletions host-tests/tests/spi.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use embedded_hal_mock::spi;
use embedded_hal_mock::pin::{
Mock as PinMock, State as PinState, Transaction as PinTransaction,
};
use embedded_hal_mock::delay::MockNoop;
use embedded_hal_mock::pin::{Mock as PinMock, State as PinState, Transaction as PinTransaction};
use embedded_hal_mock::spi;

use esp32_wroom_rp::wifi::Wifi;
use esp32_wroom_rp::gpio::EspControlInterface;
use esp32_wroom_rp::wifi::Wifi;

struct EspControlMock {}

Expand All @@ -18,7 +16,7 @@ impl EspControlInterface for EspControlMock {
true
}

fn wait_for_esp_select(&mut self) {}
fn wait_for_esp_select(&mut self) {}

fn wait_for_esp_ack(&self) {}

Expand All @@ -41,7 +39,6 @@ fn invalid_command_induces_nina_protocol_version_mismatch_error() {
spi::Transaction::transfer(vec![0x37], vec![0x0]),
spi::Transaction::transfer(vec![0x0], vec![0x0]),
spi::Transaction::transfer(vec![0xee], vec![0x0]),

// wait_response_cmd()
spi::Transaction::transfer(vec![0xff], vec![0xef]),
];
Expand All @@ -54,7 +51,12 @@ fn invalid_command_induces_nina_protocol_version_mismatch_error() {
let mut wifi = Wifi::init(&mut spi, &mut pins, &mut delay).ok().unwrap();
let f = wifi.firmware_version();

assert_eq!(f.unwrap_err(), esp32_wroom_rp::Error::Protocol(esp32_wroom_rp::protocol::ProtocolError::NinaProtocolVersionMismatch));
assert_eq!(
f.unwrap_err(),
esp32_wroom_rp::Error::Protocol(
esp32_wroom_rp::protocol::ProtocolError::NinaProtocolVersionMismatch
)
);

spi.done();
}

0 comments on commit 972d40b

Please sign in to comment.