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

Promote the pygamer BSP to Tier 1 status #766

Merged
merged 15 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
58 changes: 19 additions & 39 deletions boards/pygamer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,62 +1,54 @@
[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"
cortex-m-rtic = "1.0"
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"
embedded-sdmmc = "0.8.0"
lis3dh = "0.1.0"
cortex-m-rtic = "1.0"
micromath = "0.5.1"
panic-halt = "0.2"
smart-leds = "0.3"
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]
Expand All @@ -65,15 +57,3 @@ chip = "ATSAMD51J19A"
[[example]]
name = "usb_poll"
required-features = ["usb"]

[[example]]
name = "sd_card"
jbeaurivage marked this conversation as resolved.
Show resolved Hide resolved
required-features = ["sd-card"]

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

[[example]]
name = "pwm_tcc0"
required-features = ["math"]
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
14 changes: 7 additions & 7 deletions boards/pygamer/examples/button_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ mod app {
fn init(c: init::Context) -> (Shared, Resources, init::Monotonics) {
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 Down
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
24 changes: 12 additions & 12 deletions boards/pygamer/examples/sd_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ 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 pins = Pins::new(peripherals.PORT).split();
let pins = Pins::new(peripherals.port).split();

let mut red_led: RedLed = pins.led_pin.into();

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 All @@ -73,15 +73,15 @@ fn main() -> ! {

let gclk0 = clocks.gclk0();
let timer_clock = clocks.tc4_tc5(&gclk0).unwrap();
let mut khz_timer = TimerCounter::tc4_(&timer_clock, peripherals.TC4, &mut peripherals.MCLK);
let mut khz_timer = TimerCounter::tc4_(&timer_clock, peripherals.tc4, &mut peripherals.mclk);
InterruptDrivenTimer::start(&mut khz_timer, Hertz::kHz(1).into_duration());

let sdmmc_cs = pins.sd_cs_pin.into_push_pull_output();
let sdmmc_spi_bus = pins.spi.init(
&mut clocks,
3.MHz(),
peripherals.SERCOM1,
&mut peripherals.MCLK,
peripherals.sercom1,
&mut peripherals.mclk,
);

let sdmmc_spi =
Expand Down
14 changes: 7 additions & 7 deletions boards/pygamer/examples/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ use pac::Peripherals;
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);

let gclk0 = clocks.gclk0();
let timer_clock = clocks.tc2_tc3(&gclk0).unwrap();
let mut timer = TimerCounter::tc3_(&timer_clock, peripherals.TC3, &mut peripherals.MCLK);
let mut timer = TimerCounter::tc3_(&timer_clock, peripherals.tc3, &mut peripherals.mclk);
timer.start(Hertz::kHz(250).into_duration());
let mut d13: RedLed = pins.d13.into();

Expand Down
Loading