From 36453bfd52da7ec76b390b0011abf09ce116794c Mon Sep 17 00:00:00 2001 From: Leah Date: Thu, 25 Feb 2021 02:14:13 +0100 Subject: [PATCH 1/2] formatting for all svd files --- Cargo.lock | 322 +++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- src/idf/mod.rs | 230 +++++++++++++++++------------------ src/main.rs | 23 +++- src/sdk/mod.rs | 5 +- 5 files changed, 287 insertions(+), 295 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d199c28..a803e92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,66 +1,75 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aho-corasick" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr", ] [[package]] name = "ansi_term" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] [[package]] name = "anyhow" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9267dff192e68f3399525901e709a48c1d3982c9c072fa32f2127a0cb0babf14" [[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi", + "libc", + "winapi", ] [[package]] name = "autocfg" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "clap" version = "3.0.0-beta.1" source = "git+https://github.com/clap-rs/clap/#20daf00d519d12ec92923a7bde42cc9211823e69" dependencies = [ - "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap/)", - "indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term", + "atty", + "bitflags", + "clap_derive", + "indexmap", + "lazy_static", + "strsim", + "textwrap", + "unicode-width", + "vec_map", ] [[package]] @@ -68,453 +77,426 @@ name = "clap_derive" version = "3.0.0-beta.1" source = "git+https://github.com/clap-rs/clap/#20daf00d519d12ec92923a7bde42cc9211823e69" dependencies = [ - "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-error 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "crossbeam-deque" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" dependencies = [ - "crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch", + "crossbeam-utils", + "maybe-uninit", ] [[package]] name = "crossbeam-epoch" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cfg-if", + "crossbeam-utils", + "lazy_static", + "maybe-uninit", + "memoffset", + "scopeguard", ] [[package]] name = "crossbeam-queue" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "crossbeam-utils", ] [[package]] name = "crossbeam-utils" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cfg-if", + "lazy_static", ] [[package]] name = "either" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" [[package]] name = "header2svd" version = "0.2.0" dependencies = [ - "clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap/)", - "regex 1.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)", - "svd-parser 0.9.0 (git+https://github.com/rust-embedded/svd.git?rev=9a979456cbb64d86f0f5da855440d320ee99aa58)", - "xmltree 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap", + "regex", + "serde", + "serde_json", + "svd-parser", + "xmltree", ] [[package]] name = "heck" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" dependencies = [ - "unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation", ] [[package]] name = "hermit-abi" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" dependencies = [ - "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "indexmap" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", ] [[package]] name = "itoa" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" [[package]] name = "maybe-uninit" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[package]] name = "memchr" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" [[package]] name = "memoffset" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", ] [[package]] name = "num_cpus" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ - "hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi", + "libc", ] [[package]] name = "proc-macro-error" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" dependencies = [ - "proc-macro-error-attr 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", ] [[package]] name = "proc-macro-error-attr" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn-mid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", + "syn-mid", + "version_check", ] [[package]] name = "proc-macro2" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid", ] [[package]] name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "rayon" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" dependencies = [ - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque", + "either", + "rayon-core", ] [[package]] name = "rayon-core" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" dependencies = [ - "crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque", + "crossbeam-queue", + "crossbeam-utils", + "lazy_static", + "num_cpus", ] [[package]] name = "regex" version = "1.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" dependencies = [ - "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", ] [[package]] name = "regex-syntax" version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" [[package]] name = "ryu" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" dependencies = [ - "serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "serde_json" version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" dependencies = [ - "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa", + "ryu", + "serde", ] [[package]] name = "strsim" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "svd-parser" version = "0.9.0" source = "git+https://github.com/rust-embedded/svd.git?rev=9a979456cbb64d86f0f5da855440d320ee99aa58#9a979456cbb64d86f0f5da855440d320ee99aa58" dependencies = [ - "anyhow 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "xmltree 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow", + "rayon", + "thiserror", + "xmltree", ] [[package]] name = "syn" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] name = "syn-mid" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width", ] [[package]] name = "thiserror" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" dependencies = [ - "thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2e25d25307eb8436894f727aba8f65d07adf02e5b35a13cebed48bd282bfef" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "thread_local" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", ] [[package]] name = "unicode-segmentation" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" [[package]] name = "unicode-width" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" [[package]] name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" [[package]] name = "vec_map" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" [[package]] name = "version_check" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" [[package]] name = "winapi" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "xml-rs" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", ] -[[package]] -name = "xml-rs" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "xmltree" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff8eaee9d17062850f1e6163b509947969242990ee59a35801af437abe041e70" dependencies = [ - "xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "xml-rs", ] - -[[package]] -name = "xmltree" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "xml-rs 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -"checksum ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -"checksum anyhow 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "9267dff192e68f3399525901e709a48c1d3982c9c072fa32f2127a0cb0babf14" -"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum clap 3.0.0-beta.1 (git+https://github.com/clap-rs/clap/)" = "" -"checksum clap_derive 3.0.0-beta.1 (git+https://github.com/clap-rs/clap/)" = "" -"checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -"checksum crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -"checksum crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" -"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -"checksum hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" -"checksum indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" -"checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)" = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" -"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" -"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" -"checksum memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" -"checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -"checksum proc-macro-error 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" -"checksum proc-macro-error-attr 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" -"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" -"checksum rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" -"checksum regex 1.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" -"checksum regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" -"checksum ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" -"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -"checksum serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)" = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" -"checksum serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)" = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" -"checksum serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)" = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" -"checksum strsim 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" -"checksum svd-parser 0.9.0 (git+https://github.com/rust-embedded/svd.git?rev=9a979456cbb64d86f0f5da855440d320ee99aa58)" = "" -"checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" -"checksum syn-mid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" -"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" -"checksum thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2e25d25307eb8436894f727aba8f65d07adf02e5b35a13cebed48bd282bfef" -"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -"checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" -"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2" -"checksum xml-rs 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2bb76e5c421bbbeb8924c60c030331b345555024d56261dae8f3e786ed817c23" -"checksum xmltree 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77a607efe600db25447a8d9bab1f39217a82c4ba160b51b027d7c4f6053004df" -"checksum xmltree 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8eaee9d17062850f1e6163b509947969242990ee59a35801af437abe041e70" diff --git a/Cargo.toml b/Cargo.toml index 8aca0f8..95399a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,4 +29,4 @@ regex = "1.3.6" serde = { version = "1.0.106", features = ["derive"] } serde_json = "1.0.51" svd-parser = { git = "https://github.com/rust-embedded/svd.git", rev = "9a979456cbb64d86f0f5da855440d320ee99aa58", features = ["unproven"] } -xmltree = "0.10.0" +xmltree = "0.8.0" diff --git a/src/idf/mod.rs b/src/idf/mod.rs index 8979a69..d6ae4b4 100644 --- a/src/idf/mod.rs +++ b/src/idf/mod.rs @@ -92,133 +92,133 @@ fn parse_idf(chip: &ChipType) -> HashMap { peripherals.insert(peripheral.to_string(), p); } - std::fs::read_dir(soc_base_path) + for f in std::fs::read_dir(soc_base_path) .unwrap() .filter_map(Result::ok) .filter(|f| f.path().to_str().unwrap().ends_with("_reg.h")) - .for_each(|f| { - let name = f.path(); - let name = name.to_str().unwrap(); - let mut buffer = vec![]; - let file_data = file_to_string(name); - // println!("Searching {}", name); - let mut something_found = false; - let mut state = State::FindReg; - for (i, line) in file_data.lines().enumerate() { - loop { - match state { - State::FindReg => { - /* Normal register definitions */ - if let Some(m) = re_reg.captures(line) { - let reg_name = &m[1]; - let pname = &m[2]; - let offset = &m[3].trim_start_matches("0x"); - if reg_name.ends_with("(i)") { - invalid_registers.push(reg_name.to_string()); - // some indexed still get through, ignore them - break; - } - if let Ok(addr) = u32::from_str_radix(offset, 16) { - let mut r = Register::default(); - r.description = reg_name.to_string(); - r.name = reg_name.to_string(); - r.address = addr; - state = State::FindBitFieldInfo(pname.to_string(), r); - } else { - invalid_registers.push(reg_name.to_string()); - } - } else if let Some(m) = re_reg_index.captures(line) { - let reg_name = &m[1]; - let pname = &m[2]; - let offset = &m[3].trim_start_matches("0x"); - - if let Ok(addr) = u32::from_str_radix(offset, 16) { - let mut r = Register::default(); - r.name = reg_name.to_string(); - r.description = reg_name.to_string(); - r.address = addr; - state = State::FindBitFieldInfo(pname.to_string(), r); - } else { - invalid_registers.push(reg_name.to_string()); - } + { + let name = f.path(); + let name = name.to_str().unwrap(); + let mut buffer = vec![]; + let file_data = file_to_string(name); + // println!("Searching {}", name); + let mut something_found = false; + let mut state = State::FindReg; + for (i, line) in file_data.lines().enumerate() { + loop { + match state { + State::FindReg => { + /* Normal register definitions */ + if let Some(m) = re_reg.captures(line) { + let reg_name = &m[1]; + let pname = &m[2]; + let offset = &m[3].trim_start_matches("0x"); + if reg_name.ends_with("(i)") { + invalid_registers.push(reg_name.to_string()); + // some indexed still get through, ignore them + break; } - break; // next line - } - State::FindBitFieldInfo(ref mut pname, ref mut reg) => { - something_found = true; - if let Some(m) = re_reg_bit_info.captures(line) { - let bf_name = &m[1]; - let access_type = &m[2]; // TODO - let bits = &mut m[3].split(':'); - let _default_val = &m[4]; // TODO - let bits = match (bits.next(), bits.next()) { - (Some(h), Some(l)) => { - Bits::Range(l.parse().unwrap()..=h.parse().unwrap()) - } - (Some(b), None) => Bits::Single(b.parse().unwrap()), - _ => { - // println!("Failed to parse bitpos {}", &m[3]); - invalid_bit_fields - .push((bf_name.to_string(), m[3].to_string())); - continue; - } - }; - - let bf = BitField { - name: bf_name.to_string(), - bits, - type_: Type::from_str(access_type).unwrap_or_else(|s| { - println!("{}", s); - Type::default() - }), - reset_value: 0, - ..Default::default() - }; - state = State::FindDescription(pname.clone(), reg.clone(), bf); + if let Ok(addr) = u32::from_str_radix(offset, 16) { + let mut r = Register::default(); + r.description = reg_name.to_string(); + r.name = reg_name.to_string(); + r.address = addr; + state = State::FindBitFieldInfo(pname.to_string(), r); } else { - println!("Failed to match reg info at {}:{}", name, i); - state = State::FindReg; + invalid_registers.push(reg_name.to_string()); } - break; // next line - } - State::FindDescription(ref mut pname, ref mut reg, ref mut bf) => { - buffer.push(line); - if let Some(_m) = re_reg_desc.captures(buffer.join("").as_str()) { - buffer.clear(); - reg.bit_fields.push(bf.clone()); // add the bit field to the reg - state = State::CheckEnd(pname.clone(), reg.clone()); + } else if let Some(m) = re_reg_index.captures(line) { + let reg_name = &m[1]; + let pname = &m[2]; + let offset = &m[3].trim_start_matches("0x"); + + if let Ok(addr) = u32::from_str_radix(offset, 16) { + let mut r = Register::default(); + r.name = reg_name.to_string(); + r.description = reg_name.to_string(); + r.address = addr; + state = State::FindBitFieldInfo(pname.to_string(), r); + } else { + invalid_registers.push(reg_name.to_string()); } - break; // next line } - State::CheckEnd(ref mut pname, ref mut reg) => { - if line.is_empty() { - // println!("{} Adding {:#?}", pname, reg); - // were done with this register - if let Some(p) = peripherals.get_mut(&pname.to_string()) { - p.registers.push(reg.clone()); - } else { - // TODO indexed peripherals wont come up here - println!("No peripheral called {}", pname.to_string()); - invalid_peripherals.push(pname.to_string()); + break; // next line + } + State::FindBitFieldInfo(ref mut pname, ref mut reg) => { + something_found = true; + if let Some(m) = re_reg_bit_info.captures(line) { + let bf_name = &m[1]; + let access_type = &m[2]; // TODO + let bits = &mut m[3].split(':'); + let _default_val = &m[4]; // TODO + let bits = match (bits.next(), bits.next()) { + (Some(h), Some(l)) => { + Bits::Range(l.parse().unwrap()..=h.parse().unwrap()) + } + (Some(b), None) => Bits::Single(b.parse().unwrap()), + _ => { + // println!("Failed to parse bitpos {}", &m[3]); + invalid_bit_fields + .push((bf_name.to_string(), m[3].to_string())); + continue; } - state = State::FindReg; - break; // next line - } else if re_reg_bit_info.is_match(line) { - // weve found the next bit field in the reg - state = State::FindBitFieldInfo(pname.clone(), reg.clone()); + }; + + let bf = BitField { + name: bf_name.to_string(), + bits, + type_: Type::from_str(access_type).unwrap_or_else(|s| { + println!("{}", s); + Type::default() + }), + reset_value: 0, + ..Default::default() + }; + state = State::FindDescription(pname.clone(), reg.clone(), bf); + } else { + println!("Failed to match reg info at {}:{}", name, i); + state = State::FindReg; + } + break; // next line + } + State::FindDescription(ref mut pname, ref mut reg, ref mut bf) => { + buffer.push(line); + if let Some(_m) = re_reg_desc.captures(buffer.join("").as_str()) { + buffer.clear(); + reg.bit_fields.push(bf.clone()); // add the bit field to the reg + state = State::CheckEnd(pname.clone(), reg.clone()); + } + break; // next line + } + State::CheckEnd(ref mut pname, ref mut reg) => { + if line.is_empty() { + // println!("{} Adding {:#?}", pname, reg); + // were done with this register + if let Some(p) = peripherals.get_mut(&pname.to_string()) { + p.registers.push(reg.clone()); } else { - break; // next line + // TODO indexed peripherals wont come up here + println!("No peripheral called {}", pname.to_string()); + invalid_peripherals.push(pname.to_string()); } + state = State::FindReg; + break; // next line + } else if re_reg_bit_info.is_match(line) { + // weve found the next bit field in the reg + state = State::FindBitFieldInfo(pname.clone(), reg.clone()); + } else { + break; // next line } } } } + } - // log if nothing was parsed in this file - if !something_found { - invalid_files.push(String::from(name)) - } - }); + // log if nothing was parsed in this file + if !something_found { + invalid_files.push(String::from(name)) + } + } println!("Parsed idf for peripherals information."); @@ -255,11 +255,7 @@ fn parse_idf(chip: &ChipType) -> HashMap { peripherals } -pub fn create_svd(chip: ChipType) { +pub fn create_svd(chip: ChipType) -> ::svd_parser::Device { let peripherals = parse_idf(&chip); - let filename = format!("{}{}", chip.to_string().to_lowercase(), ".svd"); - let svd = build_svd(chip, peripherals).unwrap(); - - let f = BufWriter::new(File::create(filename).unwrap()); - svd.encode().unwrap().write(f).unwrap(); + build_svd(chip, peripherals).unwrap() } diff --git a/src/main.rs b/src/main.rs index 632fcf7..c79b717 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,10 @@ use std::str::FromStr; use clap::{app_from_crate, Arg}; use common::ChipType; +use std::fs::File; +use std::io::BufWriter; +use svd_parser::encode::Encode; +use xmltree::EmitterConfig; mod common; mod idf; @@ -22,13 +26,24 @@ fn main() { // Based on which chip has been selected, invoke the appropriate SVD // builder (since the ESP32 and ESP8266 have different SDKs). let chip = matches.value_of("CHIP").unwrap().to_uppercase(); - let chip = ChipType::from_str(&chip); - match chip { + let svd = match ChipType::from_str(&chip) { Ok(chip) => match chip { ChipType::ESP32 => idf::create_svd(chip), ChipType::ESP32C3 => idf::create_svd(chip), ChipType::ESP8266 => sdk::create_svd(), }, - Err(e) => println!("{}", e), - } + Err(e) => return println!("{}", e), + }; + + let filename = format!("{}.svd", chip.to_lowercase()); + let f = BufWriter::new(File::create(filename).unwrap()); + svd.encode() + .unwrap() + .write_with_config( + f, + EmitterConfig::new() + .perform_indent(true) + .indent_string(" "), + ) + .unwrap(); } diff --git a/src/sdk/mod.rs b/src/sdk/mod.rs index 6300f24..0e53ef7 100644 --- a/src/sdk/mod.rs +++ b/src/sdk/mod.rs @@ -382,7 +382,7 @@ fn parse_sdk() -> HashMap { peripherals } -pub fn create_svd() { +pub fn create_svd() -> ::svd_parser::Device { let mut peripherals = parse_sdk(); // where available, the docs provide more detailed info @@ -433,6 +433,5 @@ pub fn create_svd() { let mut svd = build_svd(ChipType::ESP8266, peripherals).unwrap(); svd.address_unit_bits = Some(8); - let f = BufWriter::new(File::create("esp8266.svd").unwrap()); - svd.encode().unwrap().write(f).unwrap(); + svd } From 5a65e811f756a09f88c106a72d88e7c4975600b7 Mon Sep 17 00:00:00 2001 From: Leah Date: Tue, 27 Apr 2021 22:43:57 +0200 Subject: [PATCH 2/2] even more WIP --- src/idf/mod.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/idf/mod.rs b/src/idf/mod.rs index d6ae4b4..f0a2848 100644 --- a/src/idf/mod.rs +++ b/src/idf/mod.rs @@ -9,6 +9,7 @@ use svd_parser::encode::Encode; use crate::common::{ build_svd, file_to_string, BitField, Bits, ChipType, Interrupt, Peripheral, Register, Type, }; +use xmltree::EmitterConfig; // Regexes to find all the peripheral addresses const REG_BASE: &'static str = r"\#define[\s*]+DR_REG_(.*)_BASE[\s*]+0x([0-9a-fA-F]+)"; @@ -19,6 +20,7 @@ const REG_BIT_INFO: &'static str = r"/\*[\s]+([0-9A-Za-z_]+)[\s]+:[\s]+([0-9A-Za const REG_DESC: &'static str = r"\*description:\s(.*[\n|\r|\r\n]?.*)\*/"; const INTERRUPTS: &'static str = r"\#define[\s]ETS_([0-9A-Za-z_/]+)_SOURCE[\s]+([0-9]+)/\*\*<\s([0-9A-Za-z_/\s,]+)\*/"; +const INTERRUPTS_C3: &'static str = r"\#define[\s]ETS_([0-9A-Za-z_/]+)_INUM[\s]+([0-9]+)"; enum State { FindReg, @@ -47,9 +49,28 @@ fn parse_idf(chip: &ChipType) -> HashMap { let re_reg_desc = Regex::new(REG_DESC).unwrap(); let re_reg_bit_info = Regex::new(REG_BIT_INFO).unwrap(); let re_interrupts = Regex::new(INTERRUPTS).unwrap(); + // let re_interrupts = match chip { + // ChipType::ESP32 => Regex::new(INTERRUPTS).unwrap(), + // ChipType::ESP32C3 => Regex::new(INTERRUPTS_C3).unwrap(), + // _ => unreachable!(), + // }; let soc_h = file_to_string(&filename); + // for captures in re_interrupts.captures_iter(soc_h.as_str()) { + // let name = captures.get(1).map_or("", |m| m.as_str()); + // let index = captures.get(2).map_or("", |m| m.as_str()); + // let desc = captures + // .get(3) + // .map_or(None, |m| Some(m.as_str().to_owned())); + // let intr = Interrupt { + // name: name.to_string(), + // description: desc, + // value: index.parse().unwrap(), + // }; + // interrupts.push(intr); + // } + for captures in re_interrupts.captures_iter(soc_h.as_str()) { let name = &captures[1]; let index = &captures[2];