diff --git a/Cargo.toml b/Cargo.toml index 33da0ba72ad3e940ed3ee03df21f763774ef6d28..99eb414ab43ce06b304340265e7202012b278555 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,10 +15,9 @@ volatile-register = "0.2.1" embedded-hal = "1.0.0-alpha.10" [dev-dependencies] -panic-halt = "0.2.0" +memoffset = "0.9.0" -[dev-dependencies.bl-rom-rt] -git = "https://gitee.com/rustsbi/bl-rom-rt" -branch = "main" -default-features = false -features = ["bl808-d0"] +[workspace] +members = [ + "examples/*" +] diff --git a/examples/jtag-demo/Cargo.toml b/examples/jtag-demo/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..d9a840d84ab7fa476d31598a631e723392d10a92 --- /dev/null +++ b/examples/jtag-demo/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "bl-soc-example-jtag-demo" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +bl-soc = { path = "../.." } +base-address = "0.0.0" +panic-halt = "0.2.0" +embedded-hal = "1.0.0-alpha.10" + +[dependencies.bl-rom-rt] +git = "https://gitee.com/rustsbi/bl-rom-rt" +branch = "main" +default-features = false +features = ["bl808-d0"] diff --git a/build.rs b/examples/jtag-demo/build.rs similarity index 100% rename from build.rs rename to examples/jtag-demo/build.rs diff --git a/examples/jtag-bl808-d0.rs b/examples/jtag-demo/src/main.rs similarity index 89% rename from examples/jtag-bl808-d0.rs rename to examples/jtag-demo/src/main.rs index c70da9d3b6e5e72a6224bd8428c16a20d27b053a..95c2e293b035f30d840376de8275b5965edd9207 100644 --- a/examples/jtag-bl808-d0.rs +++ b/examples/jtag-demo/src/main.rs @@ -1,6 +1,6 @@ // Build this example with: // rustup target install riscv64imac-unknown-none-elf -// cargo build --example jtag-bl808-d0 --target riscv64imac-unknown-none-elf --release +// cargo build --target riscv64imac-unknown-none-elf --release -p bl-soc-example-jtag-demo #![no_std] #![no_main] diff --git a/src/glb.rs b/src/glb.rs index 53708f922eba7ab043015bd863380e28a70eec04..702643614cbf5ea75aba13e3f18b0dbe0cc30a1f 100644 --- a/src/glb.rs +++ b/src/glb.rs @@ -335,3 +335,18 @@ pub enum Pull { Up = 1, Down = 2, } + +#[cfg(test)] +mod tests { + use super::RegisterBlock; + use memoffset::offset_of; + + #[test] + fn struct_register_block_offset() { + assert_eq!(offset_of!(RegisterBlock, gpio_config), 0x8c4); + assert_eq!(offset_of!(RegisterBlock, gpio_input), 0xac4); + assert_eq!(offset_of!(RegisterBlock, gpio_output), 0xae4); + assert_eq!(offset_of!(RegisterBlock, gpio_set), 0xaec); + assert_eq!(offset_of!(RegisterBlock, gpio_clear), 0xaf4); + } +}