Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pygamer to HAL 0.17 #750

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions boards/pygamer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- remove neopixel support and examples (currently unreliable)
- update HAL v0.14 -> v0.17 and other dependencies, fix examples
- update path of Cargo config

# v0.9.0
Expand Down
25 changes: 8 additions & 17 deletions boards/pygamer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,44 @@ edition = "2021"
exclude = ["assets"]

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

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

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

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

[dependencies.embedded-sdmmc]
version = "0.3.0"
version = "0.8.0"
optional = true

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

[dev-dependencies]
usbd-serial = "0.1"
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"
ws2812-spi = { version = "0.4.0", features = ["mosi_idle_high"] }
lis3dh = "0.1.0"
cortex-m-rtic = "1.0"
tinybmp = "0.3.1"

[features]
# ask the HAL to enable atsamd51j support
default = ["rt", "atsamd-hal/samd51j", "unproven"]
default = ["rt", "atsamd-hal/samd51j"]
rt = ["cortex-m-rt", "atsamd-hal/samd51j-rt"]
unproven = ["atsamd-hal/unproven"]
usb = ["atsamd-hal/usb", "usb-device"]
sd-card = ["embedded-sdmmc"]
math = ["micromath"]
Expand All @@ -73,10 +72,6 @@ opt-level = 's'
[package.metadata]
chip = "ATSAMD51J19A"

[[example]]
name = "usb_serial"
required-features = ["usb"]

[[example]]
name = "usb_poll"
required-features = ["usb"]
Expand All @@ -85,10 +80,6 @@ required-features = ["usb"]
name = "sd_card"
required-features = ["sd-card"]

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

[[example]]
name = "pwm_tc4"
required-features = ["math"]
Expand Down
7 changes: 4 additions & 3 deletions boards/pygamer/examples/blinky_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
#![no_std]
#![no_main]

use bsp::{entry, hal, pac, Pins, RedLed};
#[cfg(not(feature = "panic_led"))]
use panic_halt as _;
use pygamer::{entry, hal, pac, Pins};
use pygamer as bsp;

use hal::clock::GenericClockController;
use hal::delay::Delay;
Expand All @@ -27,8 +28,8 @@ fn main() -> ! {
let mut delay = Delay::new(core.SYST, &mut clocks);
delay.delay_ms(400u16);

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

let mut wdt = Watchdog::new(peripherals.WDT);
wdt.start(WatchdogTimeout::Cycles256 as u8);
Expand Down
37 changes: 20 additions & 17 deletions boards/pygamer/examples/button_rtic.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
#![no_std]
#![no_main]

use bsp::{pins::ButtonReader, pins::Keys, Pins};
use bsp::{hal, ButtonReader, Keys, Pins, RedLed};
#[cfg(not(feature = "panic_led"))]
use panic_halt as _;
use pygamer as bsp;

#[rtic::app(device = bsp::pac, peripherals = true)]
mod app {
use hal::clock::GenericClockController;
use hal::prelude::*;
use hal::time::Hertz;
use hal::timer::TimerCounter;
use rtic::app;

#[app(device = crate::hal::pac, peripherals = true)]
mod app {
use super::*;
use bsp::clock::GenericClockController;
use bsp::gpio::{OpenDrain, Output, Pa23};
use bsp::prelude::*;

#[local]
struct Local {
red_led: Pa23<Output<OpenDrain>>,
timer: bsp::timer::TimerCounter3,
struct Resources {
red_led: RedLed,
timer: hal::timer::TimerCounter3,
buttons: ButtonReader,
}

Expand All @@ -30,7 +32,7 @@ mod app {
/// period.
#[task(binds = TC3, local = [timer, red_led, buttons])]
fn tc3(c: tc3::Context) {
if c.local.timer.wait().is_ok() {
if InterruptDrivenTimer::wait(c.local.timer).is_ok() {
for event in c.local.buttons.events() {
match event {
Keys::SelectDown => {
Expand All @@ -46,7 +48,7 @@ mod app {
}

#[init]
fn init(c: init::Context) -> (Shared, Local, init::Monotonics) {
fn init(c: init::Context) -> (Shared, Resources, init::Monotonics) {
let mut device = c.device;
let mut clocks = GenericClockController::with_internal_32kosc(
device.GCLK,
Expand All @@ -56,21 +58,22 @@ mod app {
&mut device.NVMCTRL,
);

let mut 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 = bsp::timer::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());

tc3.start(200.hz());
tc3.enable_interrupt();

(
Shared {},
Local {
buttons: pins.buttons.init(&mut pins.port),
red_led: pins.led_pin.into_open_drain_output(&mut pins.port),
Resources {
buttons: pins.buttons.init(),
red_led: pins.led_pin.into(),
timer: tc3,
},
init::Monotonics(),
Expand Down
13 changes: 7 additions & 6 deletions boards/pygamer/examples/clock_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
#![no_std]
#![no_main]

use bsp::{entry, hal, pac, GclkOut, Pins};
#[cfg(not(feature = "panic_led"))]
use panic_halt as _;
use pygamer::{entry, hal, pac, Pins};
use pygamer as bsp;

use hal::clock::GenericClockController;
use pac::gclk::genctrl::SRC_A::DPLL0;
use pac::gclk::pchctrl::GEN_A::GCLK2;
use pac::gclk::genctrl::SRCSELECT_A::DPLL0;
use pac::gclk::pchctrl::GENSELECT_A::GCLK2;
use pac::Peripherals;

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

//3mhz
// Output 3 MHz clock on pin d5
let _gclk2 = clocks
.configure_gclk_divider_and_source(GCLK2, 40, DPLL0, false)
.unwrap();
pins.d5.into_function_m(&mut pins.port);
let _clock_out_pin: GclkOut = pins.d5.into();
loop {}
}
6 changes: 3 additions & 3 deletions boards/pygamer/examples/ferris_img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#![no_std]
#![no_main]

use bsp::{entry, hal, pac, Pins};
#[cfg(not(feature = "panic_led"))]
use panic_halt as _;
use pygamer::{entry, hal, pac, Pins};
use pygamer as bsp;

use embedded_graphics::prelude::*;
use embedded_graphics::primitives::{PrimitiveStyleBuilder, Rectangle};
Expand All @@ -30,7 +31,7 @@ fn main() -> ! {
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
);
let mut 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
Expand All @@ -41,7 +42,6 @@ fn main() -> ! {
&mut peripherals.MCLK,
peripherals.TC2,
&mut delay,
&mut pins.port,
)
.unwrap();

Expand Down
83 changes: 0 additions & 83 deletions boards/pygamer/examples/neopixel_adc_battery.rs

This file was deleted.

Loading