diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..11f4eed
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,27 @@
+name: Build & Check CI
+
+on: [push, pull_request]
+
+jobs:
+ ci:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ rust-toolchain: [nightly]
+ targets: [x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none-softfloat, aarch64-unknown-linux-gnu]
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@nightly
+ with:
+ toolchain: ${{ matrix.rust-toolchain }}
+ components: rust-src, clippy, rustfmt
+ targets: ${{ matrix.targets }}
+ - name: Check rust version
+ run: rustc --version --verbose
+ - name: Check code format
+ run: cargo fmt --all -- --check
+ - name: Clippy
+ run: cargo clippy --target ${{ matrix.targets }} --all-features -- -A clippy::new_without_default
+ - name: Build
+ run: cargo build --target ${{ matrix.targets }} --all-features
\ No newline at end of file
diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml
new file mode 100644
index 0000000..44d18d5
--- /dev/null
+++ b/.github/workflows/doc.yml
@@ -0,0 +1,29 @@
+name: Build & Deploy docs
+
+on: [push, pull_request]
+
+jobs:
+ doc:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ permissions:
+ contents: write
+ env:
+ default-branch: ${{ format('refs/heads/{0}', github.event.repository.default_branch) }}
+ RUSTDOCFLAGS: -D rustdoc::broken_intra_doc_links -D missing-docs
+ steps:
+ - uses: actions/checkout@v4
+ - uses: dtolnay/rust-toolchain@nightly
+ - name: Build docs
+ continue-on-error: ${{ github.ref != env.default-branch && github.event_name != 'pull_request' }}
+ run: |
+ cargo doc --no-deps --all-features
+ printf '' $(cargo tree | head -1 | cut -d' ' -f1) > target/doc/index.html
+ - name: Deploy to Github Pages
+ if: ${{ github.ref == env.default-branch }}
+ uses: JamesIves/github-pages-deploy-action@v4
+ with:
+ single-commit: true
+ branch: gh-pages
+ folder: target/doc
\ No newline at end of file
diff --git a/src/lib.rs b/src/lib.rs
index 1a26628..cd2ab3f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -8,6 +8,7 @@
//! Note:
//! - Interrupt grouping(secure state) is not supported
//! - Interrupt proiority(preempt) is not supported
+//!
//! Please contact the developer if you need this function
#![no_std]
@@ -122,6 +123,24 @@ pub const fn translate_irq(id: usize, int_type: InterruptType) -> Option
}
}
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_translate_irq() {
+ assert_eq!(translate_irq(0, InterruptType::SGI), Some(0));
+ assert_eq!(translate_irq(0, InterruptType::PPI), Some(16));
+ assert_eq!(translate_irq(0, InterruptType::SPI), Some(32));
+ assert_eq!(translate_irq(16, InterruptType::SGI), None);
+ assert_eq!(translate_irq(16, InterruptType::PPI), Some(32));
+ assert_eq!(translate_irq(16, InterruptType::SPI), Some(48));
+ assert_eq!(translate_irq(32, InterruptType::SGI), None);
+ assert_eq!(translate_irq(32, InterruptType::PPI), None);
+ assert_eq!(translate_irq(32, InterruptType::SPI), Some(32));
+ }
+}
+
impl Debug for IntId {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
if self.0 < Self::PPI_START {