Skip to content

Commit 99a48f4

Browse files
committed
Apply rustfmt to the USB code
1 parent 1805d72 commit 99a48f4

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

examples/usb_serial.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ extern crate panic_semihosting;
77

88
use cortex_m::asm::delay;
99
use cortex_m_rt::entry;
10+
use embedded_hal::digital::v2::OutputPin;
11+
use stm32f1xx_hal::usb::{Peripheral, UsbBus};
1012
use stm32f1xx_hal::{prelude::*, stm32};
11-
use stm32f1xx_hal::usb::{UsbBus, Peripheral};
1213
use usb_device::prelude::*;
1314
use usbd_serial::{SerialPort, USB_CLASS_CDC};
14-
use embedded_hal::digital::v2::OutputPin;
1515

1616
#[entry]
1717
fn main() -> ! {
@@ -81,8 +81,8 @@ fn main() -> ! {
8181
match serial.write(&buf[write_offset..count]) {
8282
Ok(len) if len > 0 => {
8383
write_offset += len;
84-
},
85-
_ => {},
84+
}
85+
_ => {}
8686
}
8787
}
8888
}

examples/usb_serial_interrupt.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ extern crate panic_semihosting;
77

88
use cortex_m::asm::{delay, wfi};
99
use cortex_m_rt::entry;
10+
use embedded_hal::digital::v2::OutputPin;
1011
use stm32f1xx_hal::stm32::{interrupt, Interrupt};
12+
use stm32f1xx_hal::usb::{Peripheral, UsbBus, UsbBusType};
1113
use stm32f1xx_hal::{prelude::*, stm32};
12-
use stm32f1xx_hal::usb::{UsbBus, UsbBusType, Peripheral};
1314
use usb_device::{bus::UsbBusAllocator, prelude::*};
1415
use usbd_serial::{SerialPort, USB_CLASS_CDC};
15-
use embedded_hal::digital::v2::OutputPin;
1616

1717
static mut USB_BUS: Option<UsbBusAllocator<UsbBusType>> = None;
1818
static mut USB_SERIAL: Option<usbd_serial::SerialPort<UsbBusType>> = None;
@@ -60,13 +60,12 @@ fn main() -> ! {
6060

6161
USB_SERIAL = Some(SerialPort::new(USB_BUS.as_ref().unwrap()));
6262

63-
let usb_dev =
64-
UsbDeviceBuilder::new(USB_BUS.as_ref().unwrap(), UsbVidPid(0x16c0, 0x27dd))
65-
.manufacturer("Fake company")
66-
.product("Serial port")
67-
.serial_number("TEST")
68-
.device_class(USB_CLASS_CDC)
69-
.build();
63+
let usb_dev = UsbDeviceBuilder::new(USB_BUS.as_ref().unwrap(), UsbVidPid(0x16c0, 0x27dd))
64+
.manufacturer("Fake company")
65+
.product("Serial port")
66+
.serial_number("TEST")
67+
.device_class(USB_CLASS_CDC)
68+
.build();
7069

7170
USB_DEVICE = Some(usb_dev);
7271
}

examples/usb_serial_rtfm.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
extern crate panic_semihosting;
88

99
use cortex_m::asm::delay;
10+
use embedded_hal::digital::v2::OutputPin;
1011
use rtfm::app;
1112
use stm32f1xx_hal::prelude::*;
12-
use stm32f1xx_hal::usb::{UsbBus, UsbBusType, Peripheral};
13+
use stm32f1xx_hal::usb::{Peripheral, UsbBus, UsbBusType};
1314
use usb_device::bus;
1415
use usb_device::prelude::*;
1516
use usbd_serial::{SerialPort, USB_CLASS_CDC};
16-
use embedded_hal::digital::v2::OutputPin;
1717

1818
#[app(device = stm32f1xx_hal::stm32)]
1919
const APP: () = {
@@ -57,13 +57,12 @@ const APP: () = {
5757

5858
let serial = SerialPort::new(USB_BUS.as_ref().unwrap());
5959

60-
let usb_dev =
61-
UsbDeviceBuilder::new(USB_BUS.as_ref().unwrap(), UsbVidPid(0x16c0, 0x27dd))
62-
.manufacturer("Fake company")
63-
.product("Serial port")
64-
.serial_number("TEST")
65-
.device_class(USB_CLASS_CDC)
66-
.build();
60+
let usb_dev = UsbDeviceBuilder::new(USB_BUS.as_ref().unwrap(), UsbVidPid(0x16c0, 0x27dd))
61+
.manufacturer("Fake company")
62+
.product("Serial port")
63+
.serial_number("TEST")
64+
.device_class(USB_CLASS_CDC)
65+
.build();
6766

6867
USB_DEV = usb_dev;
6968
SERIAL = serial;

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ pub mod spi;
160160
pub mod time;
161161
#[cfg(feature = "device-selected")]
162162
pub mod timer;
163-
#[cfg(all(feature = "stm32-usbd", any(feature = "stm32f102", feature = "stm32f103")))]
163+
#[cfg(all(
164+
feature = "stm32-usbd",
165+
any(feature = "stm32f102", feature = "stm32f103")
166+
))]
164167
pub mod usb;
165168
#[cfg(feature = "device-selected")]
166169
pub mod watchdog;

0 commit comments

Comments
 (0)