Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeaurivage authored Jan 10, 2024
2 parents 7acd83b + ceca9d4 commit cdd81bf
Show file tree
Hide file tree
Showing 17 changed files with 743 additions and 312 deletions.
381 changes: 75 additions & 306 deletions README.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion boards/feather_m0/examples/adalogger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use hal::delay::Delay;
use hal::pac::{interrupt, CorePeripherals, Peripherals};
use hal::prelude::*;
use hal::rtc;
use hal::time::U32Ext;
use hal::usb::UsbBus;

use heapless::String;
Expand Down
15 changes: 15 additions & 0 deletions boards/matrix_portal_m4/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# vim:ft=toml:
[target.thumbv7em-none-eabihf]
#runner = 'arm-none-eabi-gdb'
runner = 'probe-run --chip ATSAMD51J19A'

[build]
target = "thumbv7em-none-eabihf"
rustflags = [

# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
"-C", "link-arg=--nmagic",

"-C", "link-arg=-Tlink.x",
]
12 changes: 12 additions & 0 deletions boards/matrix_portal_m4/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Unreleased

-

# v0.1.0

- Added blinky_basic.rs example
- Added pin mapping to pin.rs

---

Changelog tracking started at v0.1.0
45 changes: 45 additions & 0 deletions boards/matrix_portal_m4/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[package]
name = "matrix_portal_m4"
version = "0.1.0"
authors = ["Salsa Steve <[email protected]>"]
description = "Board Support crate for the Matrix Portal M4"
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"
readme = "README.md"
edition = "2021"

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

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

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

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

[dependencies.cortex-m]
version = "0.7"
features = ["critical-section-single-core"]

[dev-dependencies]
panic-halt = "0.2"

[features]
# ask the HAL to enable atsamd51j support
default = ["rt", "atsamd-hal/samd51j", "atsamd-hal/samd51"]
rt = ["cortex-m-rt", "atsamd-hal/samd51j-rt"]
unproven = ["atsamd-hal/unproven"]
usb = ["atsamd-hal/usb", "usb-device"]


[[example]]
name = "blinky_basic"
26 changes: 26 additions & 0 deletions boards/matrix_portal_m4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Adafruit Matrix Portal M4 Board Support Crate

This crate provides a type-safe API for working with the [Adafruit Matrix Portal M4
board](https://www.adafruit.com/product/4745).

## Prerequisites
* Install the cross compile toolchain `rustup target add thumbv7em-none-eabihf`
* Install [cargo-hf2 the hf2 bootloader flasher tool](https://crates.io/crates/cargo-hf2) however your platform requires

## Uploading an example
Check out the repository for examples:

https://github.com/atsamd-rs/atsamd/tree/master/boards/matrix_portal_m4/examples

* Be in this directory `cd boards/matrix_portal_m4`
* Put your device in bootloader mode usually by hitting the reset button twice.
* Build and upload in one step
```
$ cargo hf2 --release --example blinky_basic --vid 0x239a --pid 0x00c9
Finished release [optimized] target(s) in 0.74s
Trying Ok(Some("Adafruit Industries")) Ok(Some("Matrix Portal M4"))
Flashing "/Users/User/atsamd/boards/matrix_portal_m4/target/thumbv7em-none-eabihf/release/examples/blinky_basic"
Finished in 0.051s
$
```
16 changes: 16 additions & 0 deletions boards/matrix_portal_m4/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
if env::var_os("CARGO_FEATURE_RT").is_some() {
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed=memory.x");
}
println!("cargo:rerun-if-changed=build.rs");
}
36 changes: 36 additions & 0 deletions boards/matrix_portal_m4/examples/blinky_basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#![no_std]
#![no_main]

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

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

#[entry]
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,
);
let mut delay = Delay::new(core.SYST, &mut clocks);
delay.delay_ms(400u16);

let pins = Pins::new(peripherals.PORT);
let mut red_led = pins.led.into_push_pull_output();

loop {
delay.delay_ms(200u8);
red_led.set_high().unwrap();
delay.delay_ms(200u8);
red_led.set_low().unwrap();
}
}
8 changes: 8 additions & 0 deletions boards/matrix_portal_m4/memory.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MEMORY
{
/* Leave 16k for the default bootloader on the Matrix Portal M4 */
FLASH (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 512K - 16K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
}
_stack_start = ORIGIN(RAM) + LENGTH(RAM);

11 changes: 11 additions & 0 deletions boards/matrix_portal_m4/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_std]

pub use atsamd_hal as hal;
pub use hal::ehal;
pub use hal::pac;

pub mod pins;
pub use pins::*;

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

0 comments on commit cdd81bf

Please sign in to comment.