Skip to content

Commit 455c7fa

Browse files
author
Andrew Tolvstad
committed
Clean up imports and crate attributes
The imports in most files appear to have been haphazardly 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.
1 parent 951e461 commit 455c7fa

File tree

19 files changed

+135
-127
lines changed

19 files changed

+135
-127
lines changed

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

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

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

6+
use tm4c129x_hal::{self as hal, prelude::*};
77
use core::fmt::Write;
88
use cortex_m_rt::entry;
9-
use hal::prelude::*;
109

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

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

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

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

6+
use tm4c123x_hal::{self as hal, prelude::*};
77
use core::fmt::Write;
88
use cortex_m_rt::entry;
9-
use hal::prelude::*;
109

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

tm4c-hal/src/delay.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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::{
4+
sysctl::Clocks,
5+
time::Hertz,
6+
};
7+
use cortex_m::peripheral::{SYST, syst::SystClkSource};
88
use embedded_hal::blocking::delay::{DelayMs, DelayUs};
99

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

3939
impl DelayMs<u16> for Delay {
4040
fn delay_ms(&mut self, ms: u16) {
41-
self.delay_ms(u32(ms));
41+
self.delay_ms(cast::u32(ms));
4242
}
4343
}
4444

4545
impl DelayMs<u8> for Delay {
4646
fn delay_ms(&mut self, ms: u8) {
47-
self.delay_ms(u32(ms));
47+
self.delay_ms(cast::u32(ms));
4848
}
4949
}
5050

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

7676
impl DelayUs<u16> for Delay {
7777
fn delay_us(&mut self, us: u16) {
78-
self.delay_us(u32(us))
78+
self.delay_us(cast::u32(us))
7979
}
8080
}
8181

8282
impl DelayUs<u8> for Delay {
8383
fn delay_us(&mut self, us: u8) {
84-
self.delay_us(u32(us))
84+
self.delay_us(cast::u32(us))
8585
}
8686
}

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: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
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,
13+
Floating,
14+
OpenDrain,
15+
OutputMode,
16+
AF3,
17+
},
18+
sysctl::{self, Clocks},
19+
hal::blocking::i2c::{Read, Write, WriteRead},
20+
time::Hertz,
21+
};
1722

1823
/// I2C error
1924
#[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 tm4c_hal::{bb, delay, time};
27+
pub use tm4c123x::{self, CorePeripherals, Peripherals};
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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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+
pub use crate::{
4+
gpio::GpioExt as _tm4c123x_hal_gpio_GpioExt,
5+
hal::prelude::*,
6+
sysctl::SysctlExt,
7+
time::U32Ext,
8+
};

tm4c123x-hal/src/serial.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
//! Serial
22
3-
use core::fmt;
4-
use core::marker::PhantomData;
3+
pub use tm4c123x::{UART0, UART1, UART2, UART3, UART4, UART5, UART6, UART7};
4+
pub use tm4c_hal::{serial::*, uart_hal_macro, uart_pin_macro};
55

6-
use crate::hal::prelude::*;
7-
use crate::hal::serial;
6+
use core::{fmt, marker::PhantomData};
87
use nb::{self, block};
9-
pub use tm4c123x::{UART0, UART1, UART2, UART3, UART4, UART5, UART6, UART7};
108
use void::Void;
9+
use crate::{
10+
hal::{prelude::*, serial},
11+
gpio::{
12+
gpioa, gpiob, gpioc, gpiod, gpioe, gpiof,
13+
AlternateFunction, OutputMode, AF1, AF2, AF8
14+
},
15+
sysctl,
16+
sysctl::Clocks,
17+
time::Bps,
18+
};
1119

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};
2320

2421
/// Serial abstraction
2522
pub struct Serial<UART, TX, RX, RTS, CTS> {

tm4c123x-hal/src/spi.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
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,
11+
OutputMode,
12+
AF1,
13+
AF2,
14+
},
15+
hal::spi::{FullDuplex, Phase, Polarity},
16+
sysctl,
17+
sysctl::Clocks,
18+
time::Hertz,
19+
};
1320

1421
use nb;
1522
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: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
//! Timers
22
3-
extern crate embedded_hal as hal;
4-
53
use tm4c_hal::time::Hertz;
6-
7-
use crate::sysctl;
8-
use hal::timer::{CountDown, Periodic};
94
use nb;
10-
use tm4c123x::{TIMER0, TIMER1, TIMER2, TIMER3, TIMER4, TIMER5};
11-
use tm4c123x::{WTIMER0, WTIMER1, WTIMER2, WTIMER3, WTIMER4, WTIMER5};
12-
13-
use crate::sysctl::Clocks;
5+
use tm4c123x::{
6+
TIMER0, TIMER1, TIMER2, TIMER3, TIMER4, TIMER5,
7+
WTIMER0, WTIMER1, WTIMER2, WTIMER3, WTIMER4, WTIMER5,
8+
};
149
use void::Void;
10+
use crate::{
11+
sysctl::{self, Clocks},
12+
hal::timer::{CountDown, Periodic}
13+
};
1514

1615
/// Hardware timers
1716
pub struct Timer<TIM> {

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 tm4c_hal::{bb, delay, time};
29+
pub use tm4c129x::{self, CorePeripherals, Peripherals};
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: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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+
pub use crate::{
4+
gpio::GpioExt as _tm4c129x_hal_gpio_GpioExt,
5+
hal::prelude::*,
6+
sysctl::SysctlExt,
7+
time::U32Ext,
8+
};

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+
hal::{prelude::*, serial},
7+
gpio::*,
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)