Skip to content

Commit fd3e06a

Browse files
committed
itsybitsy_m4: Update HAL 0.15->0.17
1 parent bb09e48 commit fd3e06a

File tree

7 files changed

+33
-34
lines changed

7 files changed

+33
-34
lines changed

boards/itsybitsy_m4/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22

3+
- update hal dependency to v0.17
34
- update path of Cargo config
45

56
# 0.8.0

boards/itsybitsy_m4/Cargo.toml

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,34 @@ readme = "README.md"
1616
[dependencies]
1717
bitbang-hal = "0.3"
1818
apa102-spi = "0.3"
19+
embedded-hal-02 = {package = "embedded-hal", version = "0.2", features = ["unproven"]}
1920
smart-leds = "0.3"
2021

2122
[dependencies.cortex-m-rt]
2223
version = "0.7"
2324
optional = true
2425

2526
[dependencies.atsamd-hal]
26-
version = "0.15"
27+
version = "0.17"
2728
default-features = false
2829

2930
[dependencies.usb-device]
30-
version = "0.2"
31+
version = "0.3.1"
3132
optional = true
3233

3334
[dev-dependencies]
34-
cortex-m = "0.7"
35-
usbd-serial = "0.1"
35+
cortex-m = {version = "0.7", features = ["critical-section-single-core"]}
36+
usbd-serial = "0.2.2"
3637
panic-halt = "0.2"
3738
panic-semihosting = "0.6"
3839

3940
[features]
4041
# ask the HAL to enable atsamd51g support
41-
default = ["rt", "atsamd-hal/samd51g", "atsamd-hal/unproven"]
42+
default = ["rt", "atsamd-hal/samd51g"]
4243
rt = ["cortex-m-rt", "atsamd-hal/samd51g-rt"]
43-
unproven = ["atsamd-hal/unproven"]
4444
usb = ["atsamd-hal/usb", "usb-device"]
4545
use_rtt = ["atsamd-hal/use_rtt"]
46+
use_semihosting = []
4647

4748
[profile.dev]
4849
incremental = false

boards/itsybitsy_m4/examples/dotstar.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use hal::{
1616
delay::Delay,
1717
pac::{CorePeripherals, Peripherals},
1818
prelude::*,
19-
time::MegaHertz,
19+
time::Hertz,
2020
timer::TimerCounter,
2121
};
2222

@@ -39,7 +39,7 @@ fn main() -> ! {
3939
let gclk0 = clocks.gclk0();
4040
let tc2_3 = clocks.tc2_tc3(&gclk0).unwrap();
4141
let mut timer = TimerCounter::tc3_(&tc2_3, peripherals.TC3, &mut peripherals.MCLK);
42-
timer.start(MegaHertz(4));
42+
InterruptDrivenTimer::start(&mut timer, Hertz::MHz(4).into_duration());
4343
let mut rgb = bsp::dotstar_bitbang(
4444
pins.dotstar_miso.into(),
4545
pins.dotstar_mosi.into(),

boards/itsybitsy_m4/examples/sercom_interrupt.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! The idea of this example is to show two different things
55
//! - How to manually configure SERCOM for a desired mode (UART in this case)
66
//! - How to enable an use SERCOM interrupts
7+
//!
78
//! The second one is particularly handy because some drivers will give
89
//! you a `poll()` or `update()` function, and you are expected to call it
910
//! on the receive interrupt of the peripheral i.e. SERCOM UART RXC
@@ -17,9 +18,9 @@
1718
//! - RX - A4
1819
//! - TX - A5
1920
//!
20-
//! > In the ATSAMX5x MCUs SERCOM UART configuration requires at least
21+
//! In the ATSAMX5x MCUs SERCOM UART configuration requires at least
2122
//! two pins from the same IOSET. You can find more info about this in
22-
//! the hal documentation or in the MCU datasheet at:
23+
//! the HAL documentation or in the MCU datasheet at:
2324
//! <https://www.microchip.com/en-us/product/ATSAMD51G19A>
2425
2526
use itsybitsy_m4 as bsp;
@@ -35,8 +36,8 @@ use cortex_m::{interrupt::Mutex, peripheral::NVIC};
3536
use bsp::hal::{
3637
clock::GenericClockController,
3738
delay::Delay,
38-
ehal::blocking::delay::DelayMs,
3939
gpio::{Pin, PushPullOutput, PA22},
40+
nb,
4041
pac::{self, interrupt, CorePeripherals, Peripherals},
4142
prelude::*,
4243
sercom::{
@@ -92,7 +93,7 @@ fn main() -> ! {
9293
// custom sercom uart configuration
9394
let mut serial_sercom0 = uart0(
9495
&mut clocks,
95-
Hertz(115200),
96+
115200.Hz(),
9697
dp.SERCOM0,
9798
&mut dp.MCLK,
9899
pins.a5,
@@ -102,7 +103,7 @@ fn main() -> ! {
102103
// labeled "default" uart
103104
let mut serial_sercom3 = bsp::uart(
104105
&mut clocks,
105-
Hertz(115200),
106+
115200.Hz(),
106107
dp.SERCOM3,
107108
&mut dp.MCLK,
108109
pins.d0_rx,

boards/itsybitsy_m4/examples/spi.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@ use bsp::{
1919
hal::{
2020
clock::GenericClockController,
2121
delay::Delay,
22-
ehal::{
23-
blocking::{delay::DelayMs, spi::Transfer},
24-
serial::Write,
25-
},
22+
nb,
2623
pac::{CorePeripherals, Peripherals},
2724
prelude::*,
28-
time::{Hertz, MegaHertz},
2925
},
3026
spi_master,
3127
};
@@ -45,15 +41,15 @@ fn main() -> ! {
4541
let mut delay = Delay::new(core.SYST, &mut clocks);
4642
let mut serial = bsp::uart(
4743
&mut clocks,
48-
Hertz(115200),
44+
115200.Hz(),
4945
peripherals.SERCOM3,
5046
&mut peripherals.MCLK,
5147
pins.d0_rx,
5248
pins.d1_tx,
5349
);
5450
let mut spi1 = spi_master(
5551
&mut clocks,
56-
MegaHertz(4),
52+
4.MHz(),
5753
peripherals.SERCOM1,
5854
&mut peripherals.MCLK,
5955
pins.sck,

boards/itsybitsy_m4/examples/usb_serial.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ use cortex_m::peripheral::NVIC;
2424
use hal::{
2525
clock::GenericClockController,
2626
dbgprint,
27-
ehal::timer::CountDown,
2827
pac::{interrupt, CorePeripherals, Peripherals},
29-
time::MegaHertz,
28+
time::Hertz,
3029
timer::TimerCounter,
30+
timer_traits::InterruptDrivenTimer,
3131
usb::UsbBus,
3232
};
3333
use smart_leds::{hsv::RGB8, SmartLedsWrite};
@@ -49,7 +49,7 @@ fn main() -> ! {
4949
let gclk0 = clocks.gclk0();
5050
let tc2_3 = clocks.tc2_tc3(&gclk0).unwrap();
5151
let mut timer = TimerCounter::tc3_(&tc2_3, peripherals.TC3, &mut peripherals.MCLK);
52-
timer.start(MegaHertz(4));
52+
timer.start(Hertz::MHz(4).into_duration());
5353
let mut rgb = bsp::dotstar_bitbang(
5454
pins.dotstar_miso.into(),
5555
pins.dotstar_mosi.into(),
@@ -83,9 +83,11 @@ fn main() -> ! {
8383
USB_SERIAL = Some(SerialPort::new(bus_allocator));
8484
USB_BUS = Some(
8585
UsbDeviceBuilder::new(bus_allocator, UsbVidPid(0x16c0, 0x27dd))
86-
.manufacturer("Fake company")
87-
.product("Serial port")
88-
.serial_number("TEST")
86+
.strings(&[StringDescriptors::new(LangID::EN)
87+
.manufacturer("Fake company")
88+
.product("Serial port")
89+
.serial_number("TEST")])
90+
.expect("Failed to set strings")
8991
.device_class(USB_CLASS_CDC)
9092
.build(),
9193
);

boards/itsybitsy_m4/src/lib.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
#[cfg(feature = "rt")]
55
pub use cortex_m_rt::entry;
66

7-
use crate::ehal::timer::CountDown;
87
pub use atsamd_hal as hal;
8+
use embedded_hal_02::timer::{CountDown, Periodic};
99
pub use hal::ehal;
1010

1111
pub use hal::{
1212
clock::GenericClockController,
13-
dbgprint,
14-
ehal::timer::Periodic,
15-
pac,
13+
dbgprint, pac,
1614
qspi::{OneShot, Qspi},
1715
sercom::{
1816
i2c, spi,
@@ -354,10 +352,10 @@ pub fn usb_allocator(
354352
dm: impl Into<UsbDm>,
355353
dp: impl Into<UsbDp>,
356354
) -> UsbBusAllocator<UsbBus> {
357-
use pac::gclk::{genctrl::SRC_A, pchctrl::GEN_A};
355+
use pac::gclk::{genctrl::SRCSELECT_A, pchctrl::GENSELECT_A};
358356

359-
clocks.configure_gclk_divider_and_source(GEN_A::GCLK2, 1, SRC_A::DFLL, false);
360-
let usb_gclk = clocks.get_gclk(GEN_A::GCLK2).unwrap();
357+
clocks.configure_gclk_divider_and_source(GENSELECT_A::GCLK2, 1, SRCSELECT_A::DFLL, false);
358+
let usb_gclk = clocks.get_gclk(GENSELECT_A::GCLK2).unwrap();
361359
let usb_clock = &clocks.usb(&usb_gclk).unwrap();
362360
let (dm, dp) = (dm.into(), dp.into());
363361
UsbBusAllocator::new(UsbBus::new(usb_clock, mclk, dm, dp, usb))
@@ -404,7 +402,7 @@ pub fn spi_master(
404402
let (miso, mosi, sck) = (miso.into(), mosi.into(), sck.into());
405403
let pads = spi::Pads::default().data_in(miso).data_out(mosi).sclk(sck);
406404
spi::Config::new(mclk, sercom1, pads, freq)
407-
.baud(baud)
405+
.baud(baud.into())
408406
.spi_mode(spi::MODE_0)
409407
.enable()
410408
}

0 commit comments

Comments
 (0)