Skip to content

Commit aba97e2

Browse files
author
Andrew Tolvstad
committed
Clean up imports and crate attributes
The imports in most files appear to have been incompletely converted from edition 2015 to edition 2018, with duplicates and repeated prefixes. Additionally, some crate attributes were set separately when they could have been set jointly. This change cleans up imports and consolidates crate attributes. Some import sections have been annotated `#[rustfmt::skip]` and manually formatted for readability.
1 parent 951e461 commit aba97e2

File tree

19 files changed

+130
-131
lines changed

19 files changed

+130
-131
lines changed

examples/tiva-c-connected-launchpad/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#![no_std]
22
#![no_main]
33

4-
extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics
5-
extern crate tm4c129x_hal as hal;
4+
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
65

76
use core::fmt::Write;
87
use cortex_m_rt::entry;
9-
use hal::prelude::*;
8+
use tm4c129x_hal::{self as hal, prelude::*};
109

1110
#[entry]
1211
fn main() -> ! {

examples/tiva-c-launchpad/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#![no_std]
22
#![no_main]
33

4-
extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics
5-
extern crate tm4c123x_hal as hal;
4+
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
65

76
use core::fmt::Write;
87
use cortex_m_rt::entry;
9-
use hal::prelude::*;
8+
use tm4c123x_hal::{self as hal, prelude::*};
109

1110
#[entry]
1211
fn main() -> ! {

tm4c-hal/src/delay.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//! Code for busy-waiting
22
3-
use crate::sysctl::Clocks;
4-
use crate::time::Hertz;
5-
use cast::u32;
6-
use cortex_m::peripheral::syst::SystClkSource;
7-
use cortex_m::peripheral::SYST;
3+
use crate::{sysctl::Clocks, time::Hertz};
4+
use cortex_m::peripheral::{syst::SystClkSource, SYST};
85
use embedded_hal::blocking::delay::{DelayMs, DelayUs};
96

107
/// System timer (SysTick) as a delay provider
@@ -38,13 +35,13 @@ impl DelayMs<u32> for Delay {
3835

3936
impl DelayMs<u16> for Delay {
4037
fn delay_ms(&mut self, ms: u16) {
41-
self.delay_ms(u32(ms));
38+
self.delay_ms(cast::u32(ms));
4239
}
4340
}
4441

4542
impl DelayMs<u8> for Delay {
4643
fn delay_ms(&mut self, ms: u8) {
47-
self.delay_ms(u32(ms));
44+
self.delay_ms(cast::u32(ms));
4845
}
4946
}
5047

@@ -75,12 +72,12 @@ impl DelayUs<u32> for Delay {
7572

7673
impl DelayUs<u16> for Delay {
7774
fn delay_us(&mut self, us: u16) {
78-
self.delay_us(u32(us))
75+
self.delay_us(cast::u32(us))
7976
}
8077
}
8178

8279
impl DelayUs<u8> for Delay {
8380
fn delay_us(&mut self, us: u8) {
84-
self.delay_us(u32(us))
81+
self.delay_us(cast::u32(us))
8582
}
8683
}

tm4c-hal/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
//! Generic implementation code for both TM4C123 and TM4C129.
22
33
#![no_std]
4-
#![deny(missing_docs)]
5-
#![deny(warnings)]
4+
#![deny(missing_docs, warnings)]
65
#![allow(deprecated)]
76

8-
extern crate embedded_hal as hal;
9-
extern crate nb;
10-
117
pub mod bb;
128
pub mod delay;
139
pub mod gpio;

tm4c123x-hal/src/gpio.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@
3434
3535
pub use tm4c_hal::gpio::*;
3636

37-
use crate::bb;
38-
use crate::hal::digital::{InputPin, OutputPin, StatefulOutputPin};
39-
use crate::sysctl;
37+
use crate::{
38+
bb,
39+
hal::digital::{InputPin, OutputPin, StatefulOutputPin},
40+
sysctl,
41+
};
4042
use core::marker::PhantomData;
4143
use tm4c_hal::gpio_macro;
4244

tm4c123x-hal/src/i2c.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
use cortex_m::asm::delay;
44
use tm4c123x::{I2C0, I2C1, I2C2, I2C3};
55

6-
use crate::gpio::gpioa::{PA6, PA7};
7-
use crate::gpio::gpiob::{PB2, PB3};
8-
use crate::gpio::gpiod::{PD0, PD1};
9-
use crate::gpio::gpioe::{PE4, PE5};
10-
11-
use crate::gpio::{AlternateFunction, Floating, OpenDrain, OutputMode, AF3};
12-
13-
use crate::sysctl::{self, Clocks};
14-
15-
use crate::hal::blocking::i2c::{Read, Write, WriteRead};
16-
use crate::time::Hertz;
6+
use crate::{
7+
gpio::{
8+
gpioa::{PA6, PA7},
9+
gpiob::{PB2, PB3},
10+
gpiod::{PD0, PD1},
11+
gpioe::{PE4, PE5},
12+
AlternateFunction, Floating, OpenDrain, OutputMode, AF3,
13+
},
14+
hal::blocking::i2c::{Read, Write, WriteRead},
15+
sysctl::{self, Clocks},
16+
time::Hertz,
17+
};
1718

1819
/// I2C error
1920
#[derive(Debug)]

tm4c123x-hal/src/lib.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
//!
2020
//! [`f3`]: https://docs.rs/f3/~0.5.1
2121
22-
#![deny(missing_docs)]
23-
#![deny(warnings)]
22+
#![deny(missing_docs, warnings)]
2423
#![allow(deprecated)]
2524
#![no_std]
2625

27-
pub use tm4c_hal::bb;
28-
pub use tm4c_hal::delay;
29-
pub use tm4c_hal::time;
26+
pub use tm4c123x::{self, CorePeripherals, Peripherals};
27+
pub use tm4c_hal::{bb, delay, time};
28+
29+
use embedded_hal as hal;
3030

3131
pub mod gpio;
3232
pub mod i2c;
@@ -35,8 +35,3 @@ pub mod serial;
3535
pub mod spi;
3636
pub mod sysctl;
3737
pub mod timer;
38-
39-
extern crate embedded_hal as hal;
40-
extern crate nb;
41-
pub use tm4c123x;
42-
pub use tm4c123x::{CorePeripherals, Peripherals};

tm4c123x-hal/src/prelude.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! Prelude
22
3-
pub use crate::gpio::GpioExt as _tm4c123x_hal_gpio_GpioExt;
4-
pub use crate::hal::prelude::*;
5-
pub use crate::sysctl::SysctlExt;
6-
pub use crate::time::U32Ext;
3+
#[rustfmt::skip]
4+
pub use crate::{
5+
gpio::GpioExt as _,
6+
hal::prelude::*,
7+
sysctl::SysctlExt,
8+
time::U32Ext,
9+
};

tm4c123x-hal/src/serial.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
//! Serial
22
3-
use core::fmt;
4-
use core::marker::PhantomData;
5-
6-
use crate::hal::prelude::*;
7-
use crate::hal::serial;
8-
use nb::{self, block};
93
pub use tm4c123x::{UART0, UART1, UART2, UART3, UART4, UART5, UART6, UART7};
4+
pub use tm4c_hal::{serial::*, uart_hal_macro, uart_pin_macro};
5+
6+
#[rustfmt::skip]
7+
use crate::{
8+
gpio::{
9+
gpioa, gpiob, gpioc, gpiod, gpioe, gpiof,
10+
AlternateFunction, OutputMode, AF1, AF2, AF8,
11+
},
12+
hal::{prelude::*, serial},
13+
sysctl,
14+
sysctl::Clocks,
15+
time::Bps,
16+
};
17+
use core::{fmt, marker::PhantomData};
18+
use nb::{self, block};
1019
use void::Void;
1120

12-
use crate::gpio::{gpioa, gpiob, gpioc, gpiod, gpioe, gpiof};
13-
use crate::gpio::{AlternateFunction, OutputMode, AF1, AF2, AF8};
14-
use crate::sysctl;
15-
use crate::sysctl::Clocks;
16-
use crate::time::Bps;
17-
18-
pub use tm4c_hal::serial::*;
19-
20-
pub use tm4c_hal::serial::*;
21-
22-
pub use tm4c_hal::{uart_hal_macro, uart_pin_macro};
23-
2421
/// Serial abstraction
2522
pub struct Serial<UART, TX, RX, RTS, CTS> {
2623
uart: UART,

tm4c123x-hal/src/spi.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
33
pub use crate::hal::spi::{Mode, MODE_0, MODE_1, MODE_2, MODE_3};
44

5-
use crate::gpio::gpioa::{PA2, PA4, PA5};
6-
use crate::gpio::gpiob::{PB4, PB6, PB7};
7-
use crate::gpio::gpiod::{PD0, PD2, PD3};
8-
use crate::gpio::{AlternateFunction, OutputMode, AF1, AF2};
9-
use crate::hal::spi::{FullDuplex, Phase, Polarity};
10-
use crate::sysctl;
11-
use crate::sysctl::Clocks;
12-
use crate::time::Hertz;
5+
use crate::{
6+
gpio::{
7+
gpioa::{PA2, PA4, PA5},
8+
gpiob::{PB4, PB6, PB7},
9+
gpiod::{PD0, PD2, PD3},
10+
AlternateFunction, OutputMode, AF1, AF2,
11+
},
12+
hal::spi::{FullDuplex, Phase, Polarity},
13+
sysctl,
14+
sysctl::Clocks,
15+
time::Hertz,
16+
};
1317

1418
use nb;
1519
use tm4c123x::{SSI0, SSI1, SSI2, SSI3};

tm4c123x-hal/src/sysctl.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
//!
2222
//! See the LM4F120 datasheet, page 228 for a full list.
2323
24-
use crate::bb;
25-
use crate::time::{Hertz, U32Ext};
26-
use cortex_m::asm::nop;
27-
2824
pub use tm4c_hal::sysctl::*;
2925

26+
use crate::{
27+
bb,
28+
time::{Hertz, U32Ext},
29+
};
30+
use cortex_m::asm::nop;
31+
3032
/// Constrained SYSCTL peripheral.
3133
pub struct Sysctl {
3234
/// Power control methods will require `&mut this.power_control` to

tm4c123x-hal/src/timer.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
//! Timers
22
3-
extern crate embedded_hal as hal;
4-
5-
use tm4c_hal::time::Hertz;
6-
7-
use crate::sysctl;
8-
use hal::timer::{CountDown, Periodic};
3+
use crate::{
4+
hal::timer::{CountDown, Periodic},
5+
sysctl::{self, Clocks},
6+
};
97
use nb;
10-
use tm4c123x::{TIMER0, TIMER1, TIMER2, TIMER3, TIMER4, TIMER5};
11-
use tm4c123x::{WTIMER0, WTIMER1, WTIMER2, WTIMER3, WTIMER4, WTIMER5};
128

13-
use crate::sysctl::Clocks;
9+
#[rustfmt::skip]
10+
use tm4c123x::{
11+
TIMER0, TIMER1, TIMER2, TIMER3, TIMER4, TIMER5,
12+
WTIMER0, WTIMER1, WTIMER2, WTIMER3, WTIMER4, WTIMER5,
13+
};
14+
use tm4c_hal::time::Hertz;
1415
use void::Void;
1516

1617
/// Hardware timers

tm4c129x-hal/src/gpio.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
3636
3737
pub use tm4c_hal::gpio::*;
3838

39-
use crate::bb;
40-
use crate::hal::digital::{InputPin, OutputPin, StatefulOutputPin};
41-
use crate::sysctl;
39+
use crate::{
40+
bb,
41+
hal::digital::{InputPin, OutputPin, StatefulOutputPin},
42+
sysctl,
43+
};
4244
use core::marker::PhantomData;
4345
use tm4c_hal::gpio_macro;
4446

tm4c129x-hal/src/i2c.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//! Inter-Integrated Circuit (I2C) bus
22
3-
use crate::gpio::*;
4-
use crate::gpio::{AlternateFunction, Floating, OpenDrain, OutputMode, AF3};
5-
use crate::hal::blocking::i2c::{Read, Write, WriteRead};
6-
use crate::sysctl::{self, Clocks};
7-
use crate::time::Hertz;
3+
use crate::{
4+
gpio::*,
5+
hal::blocking::i2c::{Read, Write, WriteRead},
6+
sysctl::{self, Clocks},
7+
time::Hertz,
8+
};
89
use cortex_m::asm::delay;
910
use tm4c129x::{I2C0, I2C1, I2C2, I2C3};
1011

tm4c129x-hal/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
#![deny(warnings)]
2626
#![allow(deprecated)]
2727

28-
pub use tm4c_hal::bb;
29-
pub use tm4c_hal::delay;
30-
pub use tm4c_hal::time;
28+
pub use tm4c129x::{self, CorePeripherals, Peripherals};
29+
pub use tm4c_hal::{bb, delay, time};
3130

3231
pub mod gpio;
3332
pub mod i2c;
@@ -37,5 +36,3 @@ pub mod serial;
3736
pub mod sysctl;
3837

3938
use embedded_hal as hal;
40-
pub use tm4c129x;
41-
pub use tm4c129x::{CorePeripherals, Peripherals};

tm4c129x-hal/src/prelude.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! Prelude
22
3-
pub use crate::gpio::GpioExt as _tm4c129x_hal_gpio_GpioExt;
4-
pub use crate::hal::prelude::*;
5-
pub use crate::sysctl::SysctlExt;
6-
pub use crate::time::U32Ext;
3+
#[rustfmt::skip]
4+
pub use crate::{
5+
gpio::GpioExt as _,
6+
hal::prelude::*,
7+
sysctl::SysctlExt,
8+
time::U32Ext,
9+
};

tm4c129x-hal/src/serial.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
//! Serial
22
3-
use core::fmt;
4-
use core::marker::PhantomData;
5-
6-
use crate::hal::prelude::*;
7-
use crate::hal::serial;
3+
use core::{fmt, marker::PhantomData};
4+
5+
use crate::{
6+
gpio::*,
7+
hal::{prelude::*, serial},
8+
sysctl::{self, Clocks},
9+
time::Bps,
10+
};
811
use nb::{self, block};
9-
pub use tm4c129x::{UART0, UART1, UART2, UART3, UART4, UART5, UART6, UART7};
1012
use void::Void;
1113

12-
use crate::gpio::*;
13-
use crate::gpio::{AlternateFunction, OutputMode, AF1};
14-
use crate::sysctl;
15-
use crate::sysctl::Clocks;
16-
use crate::time::Bps;
17-
18-
pub use tm4c_hal::serial::*;
19-
20-
pub use tm4c_hal::{uart_hal_macro, uart_pin_macro};
14+
pub use tm4c129x::{UART0, UART1, UART2, UART3, UART4, UART5, UART6, UART7};
15+
pub use tm4c_hal::{serial::*, uart_hal_macro, uart_pin_macro};
2116

2217
/// Serial abstraction
2318
pub struct Serial<UART, TX, RX, RTS, CTS> {

0 commit comments

Comments
 (0)