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

Import PAC #1

Merged
merged 2 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
# Set a default target so the docs build
target = "riscv32imac-unknown-none-elf"
21 changes: 21 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on: [push, pull_request]
name: Build and Test check
jobs:
check-arm:
name: cargo-check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: thumbv8m.main-none-eabihf
- run: cargo build --target=thumbv8m.main-none-eabihf
check-riscv:
name: cargo-check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: riscv32imac-unknown-none-elf
- run: cargo build --target=riscv32imac-unknown-none-elf
25 changes: 25 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on: [push, pull_request]
name: Clippy check
jobs:
clippy-check-arm:
runs-on: ubuntu-20.04
env:
RUSTFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: thumbv8m.main-none-eabihf
components: clippy
- run: cargo clippy --target=thumbv8m.main-none-eabihf
clippy-check-riscv:
runs-on: ubuntu-20.04
env:
RUSTFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: riscv32imac-unknown-none-elf
components: clippy
- run: cargo clippy --target=riscv32imac-unknown-none-elf
14 changes: 14 additions & 0 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on: [push, pull_request]
name: Code formatting check
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-20.04
env:
RUSTFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --check
9 changes: 9 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
on: [push, pull_request]
name: Run update.sh and check for changed files
jobs:
update-and-diff:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- run: ./update.sh
- run: git diff --exit-code
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target
Cargo.lock
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

New version for RP235x. Based on RP2040 version.
1 change: 1 addition & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Contribution to these projects is organized under the terms of the [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct)
27 changes: 27 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "rp235x-pac"
version = "0.1.0"
authors = ["The RP-RS team"]
edition = "2021"
homepage = "https://github.com/rp-rs/rp235x-pac"
description = "A Peripheral Access Crate for the Raspberry Pi RP235x microcontrollers"
license = "BSD-3-Clause"
repository = "https://github.com/rp-rs/rp235x-pac"

[package.metadata.docs.rs]
features = ["rt"]
targets = ["thumbv8m.main-none-eabihf", "riscv32imac-unknown-none-elf"]

[dependencies]
vcell = "0.1.3"
critical-section = { optional = true, version = "1.0.0" }

[target.'thumbv8m.main-none-eabihf'.dependencies]
cortex-m = "0.7.3"
cortex-m-rt = { version = ">=0.6.15,<0.8", optional = true }

[features]
rt = ["cortex-m-rt", "cortex-m-rt/device"]

[package.metadata.cargo-udeps.ignore]
normal = ["cortex-m-rt"]
17 changes: 17 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![doc = r" Builder file for Peripheral access crate generated by svd2rust tool"]
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("device.x"))
.unwrap()
.write_all(include_bytes!("device.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed=device.x");
}
println!("cargo:rerun-if-changed=build.rs");
}
45 changes: 45 additions & 0 deletions device.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
PROVIDE(TIMER0_IRQ_0 = DefaultHandler);
PROVIDE(TIMER0_IRQ_1 = DefaultHandler);
PROVIDE(TIMER0_IRQ_2 = DefaultHandler);
PROVIDE(TIMER0_IRQ_3 = DefaultHandler);
PROVIDE(TIMER1_IRQ_0 = DefaultHandler);
PROVIDE(TIMER1_IRQ_1 = DefaultHandler);
PROVIDE(TIMER1_IRQ_2 = DefaultHandler);
PROVIDE(TIMER1_IRQ_3 = DefaultHandler);
PROVIDE(PWM_IRQ_WRAP_0 = DefaultHandler);
PROVIDE(PWM_IRQ_WRAP_1 = DefaultHandler);
PROVIDE(DMA_IRQ_0 = DefaultHandler);
PROVIDE(DMA_IRQ_1 = DefaultHandler);
PROVIDE(DMA_IRQ_2 = DefaultHandler);
PROVIDE(DMA_IRQ_3 = DefaultHandler);
PROVIDE(USBCTRL_IRQ = DefaultHandler);
PROVIDE(PIO0_IRQ_0 = DefaultHandler);
PROVIDE(PIO0_IRQ_1 = DefaultHandler);
PROVIDE(PIO1_IRQ_0 = DefaultHandler);
PROVIDE(PIO1_IRQ_1 = DefaultHandler);
PROVIDE(PIO2_IRQ_0 = DefaultHandler);
PROVIDE(PIO2_IRQ_1 = DefaultHandler);
PROVIDE(IO_IRQ_BANK0 = DefaultHandler);
PROVIDE(IO_IRQ_BANK0_NS = DefaultHandler);
PROVIDE(IO_IRQ_QSPI = DefaultHandler);
PROVIDE(IO_IRQ_QSPI_NS = DefaultHandler);
PROVIDE(SIO_IRQ_FIFO = DefaultHandler);
PROVIDE(SIO_IRQ_BELL = DefaultHandler);
PROVIDE(SIO_IRQ_FIFO_NS = DefaultHandler);
PROVIDE(SIO_IRQ_BELL_NS = DefaultHandler);
PROVIDE(SIO_IRQ_MTIMECMP = DefaultHandler);
PROVIDE(CLOCKS_IRQ = DefaultHandler);
PROVIDE(SPI0_IRQ = DefaultHandler);
PROVIDE(SPI1_IRQ = DefaultHandler);
PROVIDE(UART0_IRQ = DefaultHandler);
PROVIDE(UART1_IRQ = DefaultHandler);
PROVIDE(ADC_IRQ_FIFO = DefaultHandler);
PROVIDE(I2C0_IRQ = DefaultHandler);
PROVIDE(I2C1_IRQ = DefaultHandler);
PROVIDE(OTP_IRQ = DefaultHandler);
PROVIDE(TRNG_IRQ = DefaultHandler);
PROVIDE(PLL_SYS_IRQ = DefaultHandler);
PROVIDE(PLL_USB_IRQ = DefaultHandler);
PROVIDE(POWMAN_IRQ_POW = DefaultHandler);
PROVIDE(POWMAN_IRQ_TIMER = DefaultHandler);

55 changes: 55 additions & 0 deletions sortFieldsAlphaNum.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
#set -x
set -e

# This enables easier doc consumption for humans. Sorts structs alphanumerically
# This script should only be used to alphabetize structs with #[doc] tags, for example
# struct Peripherals {
# #[doc = "ADC"]
# pub ADC: ADC,
# #[doc = "BUSCTRL"]
# pub BUSCTRL: BUSCTRL,
# ...
# }
# Struct fields without these tags can be sorted much more trivially.

# TODO: Simple: Add target files as well if we need to sort within multiple files.

# This array should be populated with enough characters to locate a struct that needs to have its fields alphabetized.
alphaTargets=('struct Peripherals')
FILE=$1

for ((i = 0; i < ${#alphaTargets[@]}; i++)); do

# File line count
maxLen=$(cat ${FILE} | wc -l)

# This will find the line number before the starting line of the block to replace
blockStart=$(cat ${FILE} | grep "${alphaTargets[$i]}" -m 1 -n | cut -d ":" -f1)

# This will find the line number after the ending line of the block to replace
blockEnd=$(cat ${FILE} | grep "${alphaTargets[$i]}" -A $maxLen | grep -m 1 -n "}" | cut -d ":" -f1)
blockEndLine=$(($blockEnd - 2)) # used for grep display count after match
blockEnd=$((blockEndLine + blockStart)) # used for tail

# Calculate the tail number needed to crop to blockEnd
blockTail=$((maxLen-blockEnd))

# This will replace the parts that need to be sorted.
toReplace=$(cat ${FILE} | grep "${alphaTargets[$i]}" -A $blockEndLine | tail -n $blockEndLine)
if [ "$(uname)" == "Darwin" ]; then
alphabetized=$(echo "$toReplace" | sed '$!N;s/\n/ /' | sort | sed 's/ /\n /')
else
alphabetized=$(echo "$toReplace" | sed '$!N;s/\n/ /' | sort | sed -E 's/\s{5}/\n /')
fi

# Grab the parts that we aren't sorting
libSrcHead=$(cat ${FILE} | head -n $blockStart)
libSrcTail=$(cat ${FILE} | tail -n $blockTail)

# Write out the sorted file
echo "$libSrcHead" > ${FILE}
echo "$alphabetized" >> ${FILE}
echo "$libSrcTail" >> ${FILE}

done
Loading