Skip to content

Commit

Permalink
Update to latest method of bsp/hal import style and rust edition (#491)
Browse files Browse the repository at this point in the history
* Update to latest method of bsp/hal import style and rust edition
  • Loading branch information
TDHolmes authored Sep 27, 2021
1 parent 7d324b5 commit a65ceea
Show file tree
Hide file tree
Showing 183 changed files with 990 additions and 868 deletions.
7 changes: 4 additions & 3 deletions boards/arduino_mkr1000/examples/blinky_basic.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#![no_std]
#![no_main]

use arduino_mkr1000 as hal;
use arduino_mkr1000 as bsp;
use bsp::hal;

#[cfg(not(feature = "use_semihosting"))]
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;

use bsp::entry;
use hal::clock::GenericClockController;
use hal::delay::Delay;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};
use hal::prelude::*;

Expand All @@ -24,7 +25,7 @@ fn main() -> ! {
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT);
let mut pins = bsp::Pins::new(peripherals.PORT);
let mut led = pins.d6.into_open_drain_output(&mut pins.port);
let mut delay = Delay::new(core.SYST, &mut clocks);
loop {
Expand Down
12 changes: 5 additions & 7 deletions boards/arduino_mkr1000/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#![no_std]

extern crate atsamd_hal as hal;
pub use atsamd_hal as hal;
pub use hal::common::*;
pub use hal::pac;

#[cfg(feature = "rt")]
extern crate cortex_m_rt;
use cortex_m_rt;
#[cfg(feature = "rt")]
pub use cortex_m_rt::entry;

Expand All @@ -15,17 +17,13 @@ use hal::time::Hertz;

use hal::sercom::{PadPin, UART5};

pub use hal::common::*;

pub use hal::target_device as pac;

use gpio::{Floating, Input, PfD, Port};

define_pins!(
/// Maps the pins to their arduino names and
/// the numbers printed on the board.
struct Pins,
target_device: target_device,
pac: pac,

/// RX
pin rx = b23,
Expand Down
7 changes: 4 additions & 3 deletions boards/arduino_mkrvidor4000/examples/blinky_basic.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#![no_std]
#![no_main]

use arduino_mkrvidor4000 as hal;
use arduino_mkrvidor4000 as bsp;
use bsp::hal;

#[cfg(not(feature = "use_semihosting"))]
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;

use bsp::entry;
use hal::clock::GenericClockController;
use hal::delay::Delay;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};
use hal::prelude::*;

Expand All @@ -24,7 +25,7 @@ fn main() -> ! {
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT);
let mut pins = bsp::Pins::new(peripherals.PORT);
let mut led = pins.led_builtin.into_open_drain_output(&mut pins.port);
let mut delay = Delay::new(core.SYST, &mut clocks);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#![no_std]
#![no_main]

use arduino_mkrvidor4000 as hal;
use arduino_mkrvidor4000 as bsp;
use bsp::hal;

#[cfg(not(feature = "use_semihosting"))]
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;

use bsp::entry;
use hal::clock::GenericClockController;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};
use hal::pad::PadPin;
use hal::prelude::*;
Expand All @@ -31,7 +32,7 @@ fn main() -> ! {
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT);
let mut pins = bsp::Pins::new(peripherals.PORT);
let mut _led = pins.led_builtin.into_open_drain_output(&mut pins.port);
let gclk0 = clocks.gclk0();

Expand Down
7 changes: 4 additions & 3 deletions boards/arduino_mkrvidor4000/examples/run_fpga.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#![no_std]
#![no_main]

use arduino_mkrvidor4000 as hal;
use arduino_mkrvidor4000 as bsp;
use bsp::hal;

#[cfg(not(feature = "use_semihosting"))]
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;

use bsp::entry;
use hal::clock::GenericClockController;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};

#[entry]
Expand All @@ -22,7 +23,7 @@ fn main() -> ! {
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT);
let mut pins = bsp::Pins::new(peripherals.PORT);

// Enable 48MHZ clock output for FPGA
// https://github.com/arduino/ArduinoCore-samd/blob/master/variants/mkrvidor4000/variant.cpp#L229
Expand Down
15 changes: 5 additions & 10 deletions boards/arduino_mkrvidor4000/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
#![no_std]

extern crate atsamd_hal as hal;
pub use atsamd_hal as hal;
pub use hal::common::*;
pub use hal::pac;

#[cfg(feature = "rt")]
extern crate cortex_m_rt;
use cortex_m_rt;
#[cfg(feature = "rt")]
pub use cortex_m_rt::entry;

#[cfg(feature = "panic_halt")]
pub extern crate panic_halt;

use hal::prelude::*;
use hal::*;

pub use hal::common::*;

pub use hal::target_device as pac;

use gpio::{Floating, Input, Port};

// The docs could be further improved with details of the specific channels etc
define_pins!(
/// Maps the pins to their arduino names and the numbers printed on the board.
/// Information from: <https://github.com/arduino/ArduinoCore-samd/blob/master/variants/mkrvidor4000/variant.cpp>
struct Pins,
target_device: target_device,
pac: pac,

/// Digital 0: PWM, TC
pin d0 = a22,
Expand Down
7 changes: 4 additions & 3 deletions boards/arduino_mkrzero/examples/blinky_basic.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#![no_std]
#![no_main]

use arduino_mkrzero as hal;
use arduino_mkrzero as bsp;
use bsp::hal;

#[cfg(not(feature = "use_semihosting"))]
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;

use bsp::entry;
use hal::clock::GenericClockController;
use hal::delay::Delay;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};
use hal::prelude::*;

Expand All @@ -24,7 +25,7 @@ fn main() -> ! {
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT);
let mut pins = bsp::Pins::new(peripherals.PORT);
let mut led = pins.led_builtin.into_open_drain_output(&mut pins.port);
let mut delay = Delay::new(core.SYST, &mut clocks);

Expand Down
7 changes: 4 additions & 3 deletions boards/arduino_mkrzero/examples/pwm.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#![no_std]
#![no_main]

use arduino_mkrzero as hal;
use arduino_mkrzero as bsp;
use bsp::hal;

#[cfg(not(feature = "use_semihosting"))]
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;

use bsp::entry;
use hal::clock::{GenericClockController, Tcc0Tcc1Clock};
use hal::delay::Delay;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};
use hal::prelude::*;
use hal::pwm::{Channel, Pwm0};
Expand All @@ -26,7 +27,7 @@ fn main() -> ! {
&mut peripherals.NVMCTRL,
);
let mut delay = Delay::new(core.SYST, &mut clocks);
let mut pins = hal::Pins::new(peripherals.PORT);
let mut pins = bsp::Pins::new(peripherals.PORT);

// PWM0_CH1 is A4 on the board - pin 19 or PA05
// see: https://github.com/arduino/ArduinoCore-samd/blob/master/variants/mkrzero/variant.cpp
Expand Down
10 changes: 5 additions & 5 deletions boards/arduino_mkrzero/examples/usb_logging.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![no_std]
#![no_main]

use arduino_mkrzero as hal;
use cortex_m;
use arduino_mkrzero as bsp;
use bsp::hal;
use usb_device;
use usbd_serial;

Expand All @@ -11,9 +11,9 @@ use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;

use bsp::entry;
use hal::clock::GenericClockController;
use hal::delay::Delay;
use hal::entry;
use hal::pac::{interrupt, CorePeripherals, Peripherals};
use hal::prelude::*;

Expand All @@ -38,12 +38,12 @@ fn main() -> ! {
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT);
let mut pins = bsp::Pins::new(peripherals.PORT);
let mut led = pins.led_builtin.into_open_drain_output(&mut pins.port);
let mut delay = Delay::new(core.SYST, &mut clocks);

let bus_allocator = unsafe {
USB_ALLOCATOR = Some(hal::usb_allocator(
USB_ALLOCATOR = Some(bsp::usb_allocator(
peripherals.USB,
&mut clocks,
&mut peripherals.PM,
Expand Down
9 changes: 3 additions & 6 deletions boards/arduino_mkrzero/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#![no_std]

extern crate atsamd_hal as hal;
pub use atsamd_hal as hal;

#[cfg(feature = "rt")]
extern crate cortex_m_rt;
#[cfg(feature = "rt")]
pub use cortex_m_rt::entry;

#[cfg(feature = "panic_halt")]
pub extern crate panic_halt;

#[cfg(feature = "usb")]
use gpio::v2::{AnyPin, PA24, PA25};
#[cfg(feature = "usb")]
Expand All @@ -24,7 +21,7 @@ use hal::*;

pub use hal::common::*;

pub use hal::target_device as pac;
pub use hal::pac;

use gpio::{Floating, Input, Port};

Expand All @@ -33,7 +30,7 @@ define_pins!(
/// Maps the pins to their arduino names and the numbers printed on the board.
/// Information from: <https://github.com/arduino/ArduinoCore-samd/blob/master/variants/mkrzero/variant.cpp>
struct Pins,
target_device: target_device,
pac: pac,

/// Digital 0: PWM, TC
pin d0 = a22,
Expand Down
7 changes: 4 additions & 3 deletions boards/arduino_nano33iot/examples/blinky_basic.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#![no_std]
#![no_main]

extern crate arduino_nano33iot as hal;
use arduino_nano33iot as bsp;
use bsp::hal;

#[cfg(not(feature = "use_semihosting"))]
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;

use bsp::entry;
use hal::clock::GenericClockController;
use hal::delay::Delay;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};
use hal::prelude::*;

Expand All @@ -24,7 +25,7 @@ fn main() -> ! {
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT);
let mut pins = bsp::Pins::new(peripherals.PORT);
let mut led = pins.led_sck.into_open_drain_output(&mut pins.port);
let mut delay = Delay::new(core.SYST, &mut clocks);

Expand Down
14 changes: 8 additions & 6 deletions boards/arduino_nano33iot/examples/i2c_ssd1306.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@
#![no_std]
#![no_main]

extern crate arduino_nano33iot as hal;
extern crate rand;
extern crate ssd1306;
use arduino_nano33iot as bsp;
use bsp::hal;

use rand;
use ssd1306;

#[cfg(not(feature = "use_semihosting"))]
use panic_halt as _;
#[cfg(feature = "use_semihosting")]
use panic_semihosting as _;

use bsp::entry;
use hal::clock::GenericClockController;
use hal::delay::Delay;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};
use hal::prelude::*;
use hal::time::KiloHertz;
Expand All @@ -45,12 +47,12 @@ fn main() -> ! {
&mut peripherals.SYSCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT);
let mut pins = bsp::Pins::new(peripherals.PORT);
let mut delay = Delay::new(core.SYST, &mut clocks);

delay.delay_ms(BOOT_DELAY_MS);

let i2c = hal::i2c_master(
let i2c = bsp::i2c_master(
&mut clocks,
KiloHertz(400),
peripherals.SERCOM4,
Expand Down
Loading

0 comments on commit a65ceea

Please sign in to comment.