-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
655 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
$ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.