-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
feather_m4_can
board, add mcan
example
- the new `feather_m4_can` board is added as a clone of `feather_m4` with the chip changed ATSAM(D->E)51J - apply changes in board layout from `Feather M4` - adapt pinmux: alternate function pins for CAN1 connecting to TCAN1051 transceiver (RX, TX, S) and BOOST_EN - add aref pin on PA03 - move battery pin from PB01 to PB00 - Neopixel: update data to be on PB02, add enable pin PB03 - add neopixel rainbow example - adapt `mcan` example from `xplain` board replacing button triggering by a periodic task
- Loading branch information
Showing
26 changed files
with
3,336 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,14 @@ | ||
# vim:ft=toml: | ||
[target.thumbv7em-none-eabihf] | ||
runner = 'arm-none-eabi-gdb' | ||
|
||
[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,9 @@ | ||
# v0.1.0 | ||
|
||
- The board is added as a clone of `feather_m4` with chip changed ATSAM(D->E)51J | ||
- Adapt pinmux: alternate function pins for CAN1 connecting to TCAN1051 transceiver | ||
- Clone `mcan` example from `atsame54_xpro` board (using periodic task instead of button) | ||
|
||
--- | ||
|
||
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,107 @@ | ||
[package] | ||
name = "feather_m4_can" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Theodore DeRego <[email protected]>"] | ||
description = "Board Support crate for the Adafruit Feather M4 CAN" | ||
keywords = ["no-std", "arm", "cortex-m", "embedded-hal", "can"] | ||
categories = ["embedded", "hardware-support", "no-std"] | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/atsamd-rs/atsamd" | ||
readme = "README.md" | ||
documentation = "https://atsamd-rs.github.io/atsamd/atsamd51j/feather_m4_can/" | ||
|
||
# for cargo flash | ||
[package.metadata] | ||
chip = "ATSAME51J19A" | ||
|
||
[dependencies.cortex-m-rt] | ||
version = "0.7" | ||
optional = true | ||
|
||
[dependencies.atsamd-hal] | ||
path = "../../hal" | ||
version = "0.15.1" | ||
default-features = false | ||
|
||
[dependencies.usb-device] | ||
version = "0.2" | ||
optional = true | ||
|
||
[dev-dependencies] | ||
mcan = "0.2" | ||
dwt-systick-monotonic = "1.1" | ||
panic-rtt-target = { version = "0.1", features = ["cortex-m"] } | ||
rtt-target = { version = "0.3", features = ["cortex-m"] } | ||
cortex-m = "0.7" | ||
usbd-serial = "0.1" | ||
cortex-m-rtic = "1.1" | ||
panic-halt = "0.2" | ||
panic-semihosting = "0.5" | ||
smart-leds = "0.3" | ||
ws2812-timer-delay = "0.3" | ||
heapless = "0.7" | ||
|
||
[features] | ||
# ask the HAL to enable atsame51j support | ||
default = ["rt", "atsamd-hal/same51j", "atsamd-hal/same51"] | ||
rt = ["cortex-m-rt", "atsamd-hal/same51j-rt"] | ||
unproven = ["atsamd-hal/unproven"] | ||
usb = ["atsamd-hal/usb", "usb-device"] | ||
can = ["atsamd-hal/can"] | ||
dma = ["atsamd-hal/dma", "unproven"] | ||
max-channels = ["dma", "atsamd-hal/dma"] | ||
|
||
|
||
[profile.dev] | ||
incremental = false | ||
codegen-units = 1 | ||
debug = true | ||
lto = true | ||
|
||
[profile.release] | ||
debug = true | ||
lto = true | ||
opt-level = "s" | ||
|
||
[[example]] | ||
name = "blinky_basic" | ||
|
||
[[example]] | ||
name = "pwm" | ||
required-features = ["unproven"] | ||
|
||
[[example]] | ||
name = "neopixel_rainbow" | ||
|
||
[[example]] | ||
name = "usb_echo" | ||
required-features = ["usb"] | ||
|
||
[[example]] | ||
name = "dmac" | ||
required-features = ["dma"] | ||
|
||
[[example]] | ||
name = "uart" | ||
required-features = ["dma"] | ||
|
||
[[example]] | ||
name = "pukcc_test" | ||
required-features = ["unproven", "usb"] | ||
|
||
[[example]] | ||
name = "nvm_dsu" | ||
required-features = ["unproven", "usb"] | ||
|
||
[[example]] | ||
name = "smart_eeprom" | ||
required-features = ["unproven", "usb"] | ||
|
||
[[example]] | ||
name = "i2c" | ||
required-features = ["atsamd-hal/dma"] | ||
|
||
[[example]] | ||
name = "mcan" | ||
required-features = ["can"] |
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 Feather M4 Board Support Crate | ||
|
||
This crate provides a type-safe API for working with the [Adafruit Feather M4 | ||
board](https://www.adafruit.com/product/3857). | ||
|
||
## 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/feather_m4_can/examples | ||
|
||
* Be in this directory `cd boards/feather_m4_can` | ||
* 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 | ||
Finished release [optimized + debuginfo] target(s) in 0.19s | ||
Searching for a connected device with known vid/pid pair. | ||
Trying Ok(Some("Adafruit Industries")) Ok(Some("PyBadge")) | ||
Flashing "/Users/User/atsamd/boards/feather_m4_can/target/thumbv7em-none-eabihf/release/examples/blinky_basic" | ||
Finished in 0.079s | ||
$ | ||
``` |
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,37 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
use feather_m4_can as bsp; | ||
#[cfg(not(feature = "use_semihosting"))] | ||
use panic_halt as _; | ||
#[cfg(feature = "use_semihosting")] | ||
use panic_semihosting as _; | ||
|
||
use bsp::entry; | ||
use bsp::hal; | ||
use hal::clock::GenericClockController; | ||
use hal::delay::Delay; | ||
use hal::pac::{CorePeripherals, Peripherals}; | ||
use hal::prelude::*; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
let mut peripherals = Peripherals::take().unwrap(); | ||
let core = CorePeripherals::take().unwrap(); | ||
let mut clocks = GenericClockController::with_external_32kosc( | ||
peripherals.GCLK, | ||
&mut peripherals.MCLK, | ||
&mut peripherals.OSC32KCTRL, | ||
&mut peripherals.OSCCTRL, | ||
&mut peripherals.NVMCTRL, | ||
); | ||
let pins = bsp::Pins::new(peripherals.PORT); | ||
let mut red_led = pins.d13.into_push_pull_output(); | ||
let mut delay = Delay::new(core.SYST, &mut clocks); | ||
loop { | ||
delay.delay_ms(2000u16); | ||
red_led.set_high().unwrap(); | ||
delay.delay_ms(2000u16); | ||
red_led.set_low().unwrap(); | ||
} | ||
} |
Oops, something went wrong.