-
Notifications
You must be signed in to change notification settings - Fork 1
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
22 changed files
with
1,266 additions
and
269 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
name: QA | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: full | ||
|
||
jobs: | ||
test: | ||
name: Tests | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
rust: | ||
- stable | ||
- beta | ||
- nightly | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
default: true | ||
profile: minimal | ||
|
||
- name: Restore cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build & test | ||
env: | ||
RUST_VERSION: ${{ matrix.rust }} | ||
OS: ${{ matrix.os }} | ||
RUSTFLAGS: -D warnings | ||
run: cargo test --features strict | ||
|
||
- name: Build default features | ||
run: cargo build --release --features strict | ||
|
||
build: | ||
name: Build for no_std thumbv7m target | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
target: | ||
- thumbv7m-none-eabi | ||
rust: | ||
- stable | ||
- beta | ||
- nightly | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
target: ${{ matrix.target }} | ||
default: true | ||
profile: minimal | ||
|
||
- name: Restore cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build | ||
run: cargo build --release --target ${{ matrix.target }} --features default,strict | ||
|
||
example_crate_build: | ||
name: Build example crate for no_std thumbv6m | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
target: | ||
- thumbv6m-none-eabi | ||
rust: | ||
- stable | ||
- beta | ||
- nightly | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
target: ${{ matrix.target }} | ||
default: true | ||
profile: minimal | ||
|
||
- name: Restore cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build | ||
run: cargo build --release --target ${{ matrix.target }} --manifest-path example/Cargo.toml | ||
|
||
code_style: | ||
name: Check code style | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
default: true | ||
components: rustfmt | ||
|
||
- run: cargo fmt --all -- --check | ||
|
||
documentation: | ||
name: Check documentation | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
default: true | ||
|
||
- name: Restore cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Check documentation | ||
run: cargo rustdoc -- -D warnings | ||
|
||
clippy: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
default: true | ||
|
||
- name: Restore cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Clippy | ||
run: cargo clippy --all-targets --all-features -- -D warnings |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/* | ||
target/* | ||
example/target/* | ||
Cargo.lock |
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,24 @@ | ||
[build] | ||
# Set the default target to match the Cortex-M0+ in the RP2040 | ||
target = "thumbv6m-none-eabi" | ||
|
||
# Target specific options | ||
[target.thumbv6m-none-eabi] | ||
# Pass some extra options to rustc, some of which get passed on to the linker. | ||
# | ||
# * linker argument --nmagic turns off page alignment of sections (which saves | ||
# flash space) | ||
# * linker argument -Tlink.x tells the linker to use link.x as the linker | ||
# script. This is usually provided by the cortex-m-rt crate, and by default | ||
# the version in that crate will include a file called `memory.x` which | ||
# describes the particular memory layout for your specific chip. | ||
# * inline-threshold=5 makes the compiler more aggressive and inlining functions | ||
# * no-vectorize-loops turns off the loop vectorizer (seeing as the M0+ doesn't | ||
# have SIMD) | ||
rustflags = [ | ||
"-C", "link-arg=--nmagic", | ||
"-C", "link-arg=-Tlink.x", | ||
"-C", "no-vectorize-loops", | ||
] | ||
|
||
runner = "elf2uf2-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 @@ | ||
[package] | ||
name = "rt-mcp2517-example-rp-pico" | ||
description = "Example/Test crate for testing thumbv6" | ||
authors = ["AtlasAero GmbH <[email protected]>", "Neomium GmbH <[email protected]>"] | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
mcp2517 = { path = "..", version = "*" } | ||
|
||
# Embedded crates | ||
embedded-hal = "1.0.0" | ||
embedded-time = "0.12.1" | ||
embedded-alloc = "0.5.1" | ||
critical-section = "1.1.2" | ||
panic-halt = "0.2.0" | ||
|
||
# Hardware support crates | ||
rp2040-hal = "0.10.1" | ||
cortex-m = "0.7.7" | ||
cortex-m-rt = "0.7.3" | ||
rp-pico = "0.9.0" | ||
rp2040-boot2 = "0.3.0" | ||
embedded-can = "0.4.1" | ||
bytes = { version = "1.6.0", default-features = false } | ||
log = "0.4.21" | ||
usb-device = "0.3.2" | ||
usbd-serial = "0.2.2" | ||
defmt = "0.3.8" | ||
defmt-serial = "0.10.0" | ||
static_cell = "2.1.0" | ||
embedded-serial = "0.5.0" | ||
fugit = { version = "0.3.7", features = ["defmt"] } | ||
|
||
[patch.crates-io] | ||
bytes = { git = "https://github.com/atlas-aero/rt-bytes.git", branch = "cfg_target_has_atomic_v1.6.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,15 @@ | ||
MEMORY { | ||
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100 | ||
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100 | ||
RAM : ORIGIN = 0x20000000, LENGTH = 256K | ||
} | ||
|
||
EXTERN(BOOT2_FIRMWARE) | ||
|
||
SECTIONS { | ||
/* ### Boot loader */ | ||
.boot2 ORIGIN(BOOT2) : | ||
{ | ||
KEEP(*(.boot2)); | ||
} > BOOT2 | ||
} INSERT BEFORE .text; |
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,50 @@ | ||
use crate::mutex::Mutex; | ||
use embedded_time::clock::Error; | ||
use embedded_time::duration::{Duration, Fraction}; | ||
use embedded_time::fixed_point::FixedPoint; | ||
use embedded_time::timer::param::{Armed, OneShot}; | ||
use embedded_time::{Clock, Instant, Timer}; | ||
use rp2040_hal::Timer as PicoTimer; | ||
|
||
pub struct SystemClock { | ||
inner: Mutex<Option<PicoTimer>>, | ||
} | ||
|
||
impl SystemClock { | ||
pub const fn default() -> Self { | ||
Self { | ||
inner: Mutex::new(None), | ||
} | ||
} | ||
|
||
pub fn initialize(&self, timer: PicoTimer) { | ||
self.inner.replace(Some(timer)) | ||
} | ||
|
||
/// Returns the current ticks in us since startup | ||
pub fn get_ticks(&self) -> u64 { | ||
let mut ticks = 0; | ||
|
||
self.inner.access(|timer| { | ||
ticks = timer.as_ref().unwrap().get_counter().ticks(); | ||
}); | ||
|
||
ticks | ||
} | ||
} | ||
|
||
impl Clock for SystemClock { | ||
type T = u64; | ||
const SCALING_FACTOR: Fraction = Fraction::new(1, 1_000_000); | ||
|
||
fn try_now(&self) -> Result<Instant<Self>, Error> { | ||
Ok(Instant::new(self.get_ticks())) | ||
} | ||
|
||
fn new_timer<Dur: Duration>(&self, duration: Dur) -> Timer<OneShot, Armed, Self, Dur> | ||
where | ||
Dur: FixedPoint, | ||
{ | ||
Timer::new(self, duration) | ||
} | ||
} |
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,17 @@ | ||
use embedded_alloc::Heap as EmbeddedAllocHeap; | ||
|
||
#[global_allocator] | ||
static HEAP: EmbeddedAllocHeap = EmbeddedAllocHeap::empty(); | ||
|
||
const HEAP_SIZE: usize = 65_536; | ||
|
||
pub struct Heap {} | ||
|
||
impl Heap { | ||
pub fn init() { | ||
use core::mem::MaybeUninit; | ||
|
||
static mut HEAP_MEM: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE]; | ||
unsafe { HEAP.init(HEAP_MEM.as_ptr() as usize, HEAP_SIZE) } | ||
} | ||
} |
Oops, something went wrong.