Skip to content

Commit

Permalink
deps(pygamer)!: Update pygamer HAL dependency to 0.18 and promote to …
Browse files Browse the repository at this point in the history
…Tier 1 status (#766)

* Update all pygamer examples using HAL v0.18.0

* Promote `pygamer` to Tier 1

* Upgrade the following `pygamer` dependencies:
* micromath: 0.5.1 -> 2.1
* smart-leds: 0.3 -> 0.4
* lis3dh: 0.1.0 -> 0.4.3
* cortex-m-rtic 1.0 -> rtic 2.1.1

---------

Co-authored-by: Dan Whitman <[email protected]>
Co-authored-by: Justin Beaurivage <[email protected]>
Co-authored-by: Dan Whitman <[email protected]>
  • Loading branch information
4 people authored Oct 30, 2024
1 parent ef7a1b2 commit 250764c
Show file tree
Hide file tree
Showing 20 changed files with 155 additions and 1,756 deletions.
75 changes: 41 additions & 34 deletions boards/pygamer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,79 +1,86 @@
[package]
name = "pygamer"
version = "0.10.0"
authors = [
"Paul Sajna <[email protected]>",
"Wez Furlong <[email protected]>"
"Paul Sajna <[email protected]>",
"Wez Furlong <[email protected]>",
]
categories = ["embedded", "hardware-support", "no-std"]
description = "Board Support crate for the Adafruit PyGamer"
edition = "2021"
exclude = ["assets"]
keywords = ["no-std", "arm", "cortex-m", "embedded-hal"]
categories = ["embedded", "hardware-support", "no-std"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/atsamd-rs/atsamd"
name = "pygamer"
readme = "README.md"
edition = "2021"
exclude = ["assets"]
repository = "https://github.com/atsamd-rs/atsamd"
version = "0.10.0"

[dependencies]
cortex-m = {version = "0.7", features = ["critical-section-single-core"]}
st7735-lcd = "0.8.1"

[dependencies.cortex-m-rt]
version = "0.7"
optional = true
version = "0.7"

[dependencies.atsamd-hal]
version = "0.17"
default-features = false

[dependencies.micromath]
version = "0.5.1"
optional = true

[dependencies.embedded-sdmmc]
version = "0.8.0"
optional = true
path = "../../hal"
version = "0.18.0"

[dependencies.usb-device]
version = "0.3.1"
optional = true
version = "0.3.1"

[dev-dependencies]
usbd-serial = "0.2"
panic-halt = "0.2"
embedded-graphics = "0.7.1"
embedded-hal-02 = {package = "embedded-hal", version = "0.2", features = ["unproven"]}
embedded-hal-bus = "0.2.0"
smart-leds = "0.3"
lis3dh = "0.1.0"
cortex-m-rtic = "1.0"
embedded-sdmmc = "0.8.0"
lis3dh = "0.4.3"
micromath = "2.1"
panic-halt = "0.2"
rtic = {version = "2.1.1", features = ["thumbv7-backend"]}
smart-leds = "0.4"
tinybmp = "0.3.1"
usbd-serial = "0.2"

[features]
# ask the HAL to enable atsamd51j support
default = ["rt", "atsamd-hal/samd51j"]
panic_led = []
rt = ["cortex-m-rt", "atsamd-hal/samd51j-rt"]
usb = ["atsamd-hal/usb", "usb-device"]
sd-card = ["embedded-sdmmc"]
math = ["micromath"]
panic_led = []

# for cargo flash
[package.metadata]
chip = "ATSAMD51J19A"

[[example]]
name = "usb_poll"
required-features = ["usb"]
name = "blinky_basic"

[[example]]
name = "sd_card"
required-features = ["sd-card"]
name = "button_rtic"

[[example]]
name = "clock_out"

[[example]]
name = "ferris_img"

[[example]]
name = "pwm_tc4"
required-features = ["math"]

[[example]]
name = "pwm_tcc0"
required-features = ["math"]

[[example]]
name = "qspi"

[[example]]
name = "sd_card"

[[example]]
name = "timer"

[[example]]
name = "usb_poll"
required-features = ["usb"]
Binary file removed boards/pygamer/assets/ferris.raw
Binary file not shown.
Binary file removed boards/pygamer/assets/ferris1.raw
Binary file not shown.
Binary file removed boards/pygamer/assets/ferris2.raw
Binary file not shown.
14 changes: 7 additions & 7 deletions boards/pygamer/examples/blinky_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);
let mut delay = Delay::new(core.SYST, &mut clocks);
delay.delay_ms(400u16);

let pins = Pins::new(peripherals.PORT);
let pins = Pins::new(peripherals.port);
let mut red_led: RedLed = pins.d13.into();

let mut wdt = Watchdog::new(peripherals.WDT);
let mut wdt = Watchdog::new(peripherals.wdt);
wdt.start(WatchdogTimeout::Cycles256 as u8);

loop {
Expand Down
19 changes: 9 additions & 10 deletions boards/pygamer/examples/button_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use hal::time::Hertz;
use hal::timer::TimerCounter;
use rtic::app;

#[app(device = crate::hal::pac, peripherals = true)]
#[app(device = crate::hal::pac, dispatchers = [EVSYS_0])]
mod app {
use super::*;

Expand Down Expand Up @@ -48,22 +48,22 @@ mod app {
}

#[init]
fn init(c: init::Context) -> (Shared, Resources, init::Monotonics) {
fn init(c: init::Context) -> (Shared, Resources) {
let mut device = c.device;
let mut clocks = GenericClockController::with_internal_32kosc(
device.GCLK,
&mut device.MCLK,
&mut device.OSC32KCTRL,
&mut device.OSCCTRL,
&mut device.NVMCTRL,
device.gclk,
&mut device.mclk,
&mut device.osc32kctrl,
&mut device.oscctrl,
&mut device.nvmctrl,
);

let pins = Pins::new(device.PORT).split();
let pins = Pins::new(device.port).split();

let gclk0 = clocks.gclk0();
let timer_clock = clocks.tc2_tc3(&gclk0).unwrap();

let mut tc3 = TimerCounter::tc3_(&timer_clock, device.TC3, &mut device.MCLK);
let mut tc3 = TimerCounter::tc3_(&timer_clock, device.tc3, &mut device.mclk);

InterruptDrivenTimer::start(&mut tc3, Hertz::Hz(200).into_duration());

Expand All @@ -76,7 +76,6 @@ mod app {
red_led: pins.led_pin.into(),
timer: tc3,
},
init::Monotonics(),
)
}
}
18 changes: 9 additions & 9 deletions boards/pygamer/examples/clock_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ use panic_halt as _;
use pygamer as bsp;

use hal::clock::GenericClockController;
use pac::gclk::genctrl::SRCSELECT_A::DPLL0;
use pac::gclk::pchctrl::GENSELECT_A::GCLK2;
use pac::gclk::genctrl::Srcselect::Dpll0;
use pac::gclk::pchctrl::Genselect::Gclk2;
use pac::Peripherals;

#[entry]
fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);
let pins = Pins::new(peripherals.PORT);
let pins = Pins::new(peripherals.port);

// Output 3 MHz clock on pin d5
let _gclk2 = clocks
.configure_gclk_divider_and_source(GCLK2, 40, DPLL0, false)
.configure_gclk_divider_and_source(Gclk2, 40, Dpll0, false)
.unwrap();
let _clock_out_pin: GclkOut = pins.d5.into();
loop {}
Expand Down
18 changes: 9 additions & 9 deletions boards/pygamer/examples/ferris_img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);
let pins = Pins::new(peripherals.PORT).split();
let pins = Pins::new(peripherals.port).split();
let mut delay = hal::delay::Delay::new(core.SYST, &mut clocks);

let (mut display, _backlight) = pins
.display
.init(
&mut clocks,
peripherals.SERCOM4,
&mut peripherals.MCLK,
peripherals.TC2,
peripherals.sercom4,
&mut peripherals.mclk,
peripherals.tc2,
&mut delay,
)
.unwrap();
Expand Down
16 changes: 8 additions & 8 deletions boards/pygamer/examples/pwm_tc4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);

let mut delay = Delay::new(core.SYST, &mut clocks);
delay.delay_ms(400u16);

let pins = Pins::new(peripherals.PORT);
let pins = Pins::new(peripherals.port);

let gclk = clocks.gclk0();

let mut pwm0 = Pwm4::new(
&clocks.tc4_tc5(&gclk).unwrap(),
1.kHz(),
peripherals.TC4,
peripherals.tc4,
TC4Pinout::Pa23(pins.d13),
&mut peripherals.MCLK,
&mut peripherals.mclk,
);
let max_duty = pwm0.get_max_duty();

Expand Down
16 changes: 8 additions & 8 deletions boards/pygamer/examples/pwm_tcc0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);

let mut delay = Delay::new(core.SYST, &mut clocks);
delay.delay_ms(400u16);

let pins = Pins::new(peripherals.PORT);
let pins = Pins::new(peripherals.port);

let gclk = clocks.gclk0();

Expand All @@ -40,9 +40,9 @@ fn main() -> ! {
let mut pwm0 = Tcc0Pwm::new(
&clocks.tcc0_tcc1(&gclk).unwrap(),
1.kHz(),
peripherals.TCC0,
peripherals.tcc0,
TCC0Pinout::Pa23(tcc0_pin),
&mut peripherals.MCLK,
&mut peripherals.mclk,
);
let max_duty = pwm0.get_max_duty();

Expand Down
14 changes: 7 additions & 7 deletions boards/pygamer/examples/qspi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
peripherals.gclk,
&mut peripherals.mclk,
&mut peripherals.osc32kctrl,
&mut peripherals.oscctrl,
&mut peripherals.nvmctrl,
);
let mut delay = Delay::new(core.SYST, &mut clocks);

let sets = Pins::new(peripherals.PORT).split();
let sets = Pins::new(peripherals.port).split();

let mut flash = sets.flash.init(&mut peripherals.MCLK, peripherals.QSPI);
let mut flash = sets.flash.init(&mut peripherals.mclk, peripherals.qspi);

// Startup delay. Can't find documented but Adafruit use 5ms
delay.delay_ms(5u8);
Expand Down
Loading

0 comments on commit 250764c

Please sign in to comment.