Skip to content

Commit 162083a

Browse files
committed
Updated to edition 2018, bumped crate version to 0.8.0
Signed-off-by: Daniel Egger <[email protected]>
1 parent 3024514 commit 162083a

18 files changed

+112
-151
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[package]
2+
edition = "2018"
23
authors = ["Daniel Egger <[email protected]>"]
34
categories = [
45
"embedded",
@@ -17,12 +18,12 @@ license = "0BSD"
1718
name = "stm32f0xx-hal"
1819
readme = "README.md"
1920
repository = "https://github.com/stm32-rs/stm32f0xx-hal"
20-
version = "0.7.0"
21+
version = "0.8.0"
2122

2223
[dependencies]
2324
bare-metal = { version = "0.2.4", features = ["const-fn"] }
2425
cortex-m = "0.5.8"
25-
cortex-m-rt = "0.6.5"
26+
cortex-m-rt = "0.6.6"
2627
nb = "0.1.1"
2728
void = { version = "1.0.2", default-features = false }
2829
stm32f0 = "0.4.0"
@@ -36,7 +37,7 @@ features = ["unproven"]
3637
version = "0.2.2"
3738

3839
[dev-dependencies]
39-
ina260 = "0.2.3"
40+
ina260 = "0.2.6"
4041
numtoa = "0.2.3"
4142
panic-halt = "0.2.0"
4243

examples/blinky.rs

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

4-
extern crate cortex_m_rt;
5-
extern crate panic_halt;
4+
use panic_halt;
65

7-
extern crate stm32f0xx_hal as hal;
6+
use stm32f0xx_hal as hal;
87

9-
use hal::prelude::*;
10-
use hal::stm32;
8+
use crate::hal::prelude::*;
9+
use crate::hal::stm32;
1110

1211
use cortex_m_rt::entry;
1312

examples/blinky_delay.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#![no_main]
22
#![no_std]
33

4-
extern crate cortex_m;
5-
extern crate cortex_m_rt;
6-
extern crate panic_halt;
4+
use panic_halt;
75

8-
extern crate stm32f0xx_hal as hal;
6+
use stm32f0xx_hal as hal;
97

10-
use hal::delay::Delay;
11-
use hal::prelude::*;
12-
use hal::stm32;
8+
use crate::hal::delay::Delay;
9+
use crate::hal::prelude::*;
10+
use crate::hal::stm32;
1311

1412
use cortex_m::peripheral::Peripherals;
1513
use cortex_m_rt::entry;
@@ -23,7 +21,7 @@ fn main() -> ! {
2321
let mut led = gpioa.pa1.into_push_pull_output();
2422

2523
/* Constrain clocking registers */
26-
let mut rcc = p.RCC.constrain();
24+
let rcc = p.RCC.constrain();
2725

2826
/* Configure clock to 8 MHz (i.e. the default) and freeze it */
2927
let clocks = rcc.cfgr.sysclk(8.mhz()).freeze();

examples/flash_systick.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#![no_main]
22
#![no_std]
33

4-
extern crate cortex_m;
5-
extern crate cortex_m_rt;
6-
extern crate panic_halt;
4+
use panic_halt;
75

8-
extern crate stm32f0xx_hal as hal;
6+
use stm32f0xx_hal as hal;
97

10-
use hal::gpio::*;
11-
use hal::prelude::*;
12-
use hal::stm32;
8+
use crate::hal::gpio::*;
9+
use crate::hal::prelude::*;
10+
use crate::hal::stm32;
1311

1412
use cortex_m::interrupt::Mutex;
1513
use cortex_m::peripheral::syst::SystClkSource::Core;
@@ -25,12 +23,12 @@ static GPIO: Mutex<RefCell<Option<gpioa::PA1<Output<PushPull>>>>> = Mutex::new(R
2523
fn main() -> ! {
2624
if let (Some(p), Some(cp)) = (stm32::Peripherals::take(), Peripherals::take()) {
2725
let gpioa = p.GPIOA.split();
28-
let mut rcc = p.RCC.constrain();
26+
let rcc = p.RCC.constrain();
2927
let _ = rcc.cfgr.sysclk(48.mhz()).freeze();
3028
let mut syst = cp.SYST;
3129

3230
/* (Re-)configure PA1 as output */
33-
let mut led = gpioa.pa1.into_push_pull_output();
31+
let led = gpioa.pa1.into_push_pull_output();
3432

3533
cortex_m::interrupt::free(move |cs| {
3634
*GPIO.borrow(cs).borrow_mut() = Some(led);

examples/i2c_hal_ina260reader.rs

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

4-
extern crate cortex_m;
5-
extern crate cortex_m_rt;
6-
extern crate embedded_hal;
7-
extern crate panic_halt;
4+
use panic_halt;
85

9-
extern crate stm32f0xx_hal as hal;
6+
use stm32f0xx_hal as hal;
107

11-
extern crate numtoa;
12-
13-
use hal::i2c::*;
14-
use hal::prelude::*;
15-
use hal::stm32;
8+
use crate::hal::i2c::*;
9+
use crate::hal::prelude::*;
10+
use crate::hal::stm32;
1611

1712
use embedded_hal::blocking::i2c::Write;
1813

@@ -45,7 +40,7 @@ const SSD1306_CHARGE_PUMP: u8 = 0x8D;
4540
fn main() -> ! {
4641
if let Some(p) = stm32::Peripherals::take() {
4742
let gpiof = p.GPIOF.split();
48-
let mut rcc = p.RCC.constrain();
43+
let rcc = p.RCC.constrain();
4944
let _ = rcc.cfgr.freeze();
5045

5146
let scl = gpiof

examples/i2c_hal_ina260serial.rs

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

4-
extern crate cortex_m;
5-
extern crate cortex_m_rt;
6-
extern crate embedded_hal;
7-
extern crate panic_halt;
4+
use panic_halt;
85

9-
extern crate stm32f0xx_hal as hal;
6+
use stm32f0xx_hal as hal;
107

11-
extern crate ina260;
12-
extern crate numtoa;
13-
14-
use hal::i2c::*;
15-
use hal::prelude::*;
16-
use hal::serial::*;
17-
use hal::stm32;
8+
use crate::hal::i2c::*;
9+
use crate::hal::prelude::*;
10+
use crate::hal::serial::*;
11+
use crate::hal::stm32;
1812

1913
use numtoa::NumToA;
2014

@@ -28,7 +22,7 @@ fn main() -> ! {
2822
if let Some(p) = stm32::Peripherals::take() {
2923
let gpiof = p.GPIOF.split();
3024
let gpioa = p.GPIOA.split();
31-
let mut clocks = p.RCC.constrain().cfgr.freeze();
25+
let clocks = p.RCC.constrain().cfgr.freeze();
3226

3327
/* Initialise serial pins */
3428
let tx = gpioa.pa9.into_alternate_af1();
@@ -51,7 +45,7 @@ fn main() -> ! {
5145
.set_open_drain();
5246

5347
/* Setup I2C1 */
54-
let mut i2c = I2c::i2c1(p.I2C1, (scl, sda), 1.khz());
48+
let i2c = I2c::i2c1(p.I2C1, (scl, sda), 1.khz());
5549
let mut ina260 = INA260::new(i2c, 0x40).unwrap();
5650

5751
/* Endless loop */

examples/i2c_hal_ssd1306alphabeter.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
#![no_main]
22
#![no_std]
33

4-
extern crate cortex_m;
5-
extern crate cortex_m_rt;
6-
extern crate embedded_hal;
7-
extern crate panic_halt;
4+
use panic_halt;
85

9-
extern crate stm32f0xx_hal as hal;
6+
use stm32f0xx_hal as hal;
107

11-
use hal::i2c::*;
12-
use hal::prelude::*;
13-
use hal::stm32;
8+
use crate::hal::i2c::*;
9+
use crate::hal::prelude::*;
10+
use crate::hal::stm32;
1411

1512
use cortex_m_rt::entry;
1613
use embedded_hal::blocking::i2c::Write;
@@ -40,7 +37,7 @@ const SSD1306_CHARGE_PUMP: u8 = 0x8D;
4037
fn main() -> ! {
4138
if let Some(p) = stm32::Peripherals::take() {
4239
let gpiof = p.GPIOF.split();
43-
let mut rcc = p.RCC.constrain();
40+
let rcc = p.RCC.constrain();
4441
let _ = rcc.cfgr.freeze();
4542

4643
let scl = gpiof

examples/led_hal_button_irq.rs

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

4-
extern crate cortex_m;
5-
extern crate cortex_m_rt;
6-
extern crate panic_halt;
4+
use panic_halt;
75

8-
#[macro_use]
9-
extern crate stm32f0xx_hal as hal;
6+
use stm32f0xx_hal as hal;
107

11-
use hal::delay::Delay;
12-
use hal::gpio::*;
13-
use hal::prelude::*;
8+
use crate::hal::delay::Delay;
9+
use crate::hal::gpio::*;
10+
use crate::hal::prelude::*;
1411

1512
use cortex_m::interrupt::Mutex;
1613
use cortex_m::peripheral::Peripherals as c_m_Peripherals;
1714
use cortex_m_rt::entry;
1815

19-
pub use hal::stm32;
20-
pub use hal::stm32::*;
16+
pub use crate::hal::interrupt;
17+
pub use crate::hal::stm32;
18+
pub use crate::hal::stm32::*;
2119

2220
use core::cell::RefCell;
2321
use core::ops::DerefMut;
@@ -39,7 +37,7 @@ fn main() -> ! {
3937
let exti = p.EXTI;
4038

4139
// Enable clock for SYSCFG
42-
let mut rcc = p.RCC;
40+
let rcc = p.RCC;
4341
rcc.apb2enr.modify(|_, w| w.syscfgen().set_bit());
4442

4543
// Configure PB1 as input (button)
@@ -55,7 +53,7 @@ fn main() -> ! {
5553
let clocks = rcc.constrain().cfgr.sysclk(8.mhz()).freeze();
5654

5755
// Initialise delay provider
58-
let mut delay = Delay::new(cp.SYST, clocks);
56+
let delay = Delay::new(cp.SYST, clocks);
5957

6058
// Enable external interrupt for PB1
6159
syscfg

examples/serial_echo.rs

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

4-
extern crate cortex_m;
5-
extern crate cortex_m_rt;
6-
extern crate panic_halt;
4+
use panic_halt;
75

8-
extern crate stm32f0xx_hal as hal;
6+
use stm32f0xx_hal as hal;
97

10-
use hal::prelude::*;
11-
use hal::stm32;
8+
use crate::hal::prelude::*;
9+
use crate::hal::serial::Serial;
10+
use crate::hal::stm32;
1211

13-
#[macro_use(block)]
14-
extern crate nb;
15-
16-
use hal::serial::Serial;
12+
use nb::block;
1713

1814
use cortex_m_rt::entry;
1915

2016
#[entry]
2117
fn main() -> ! {
2218
if let Some(p) = stm32::Peripherals::take() {
2319
let gpioa = p.GPIOA.split();
24-
let mut rcc = p.RCC.constrain();
20+
let rcc = p.RCC.constrain();
2521
let clocks = rcc.cfgr.sysclk(48.mhz()).freeze();
2622

2723
let tx = gpioa.pa9.into_alternate_af1();

examples/spi_hal_apa102c.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#![no_main]
22
#![no_std]
33

4-
extern crate cortex_m;
5-
extern crate cortex_m_rt;
6-
extern crate panic_halt;
4+
use panic_halt;
75

8-
extern crate stm32f0xx_hal as hal;
6+
use stm32f0xx_hal as hal;
97

10-
use hal::prelude::*;
11-
use hal::spi::Spi;
12-
use hal::spi::{Mode, Phase, Polarity};
13-
use hal::stm32;
8+
use crate::hal::prelude::*;
9+
use crate::hal::spi::Spi;
10+
use crate::hal::spi::{Mode, Phase, Polarity};
11+
use crate::hal::stm32;
1412

1513
use cortex_m_rt::entry;
1614

@@ -22,9 +20,9 @@ fn main() -> ! {
2220
};
2321

2422
if let Some(p) = stm32::Peripherals::take() {
25-
let mut rcc = p.RCC.constrain();
23+
let rcc = p.RCC.constrain();
2624
let clocks = rcc.cfgr.freeze();
27-
let mut gpioa = p.GPIOA.split();
25+
let gpioa = p.GPIOA.split();
2826

2927
// Configure pins for SPI
3028
let sck = gpioa.pa5.into_alternate_af0();

0 commit comments

Comments
 (0)