From ddc5f0e8f7321b282b44d5f70a6c2d111e9bf30c Mon Sep 17 00:00:00 2001 From: Gaute Hope Date: Mon, 17 Jun 2024 09:11:19 +0200 Subject: [PATCH 1/3] eh1: delay --- ambiq-hal/Cargo.lock | 429 +++++++++++++++++++++++++++-------------- ambiq-hal/Cargo.toml | 14 +- ambiq-hal/src/delay.rs | 63 +----- 3 files changed, 298 insertions(+), 208 deletions(-) diff --git a/ambiq-hal/Cargo.lock b/ambiq-hal/Cargo.lock index 0efcc63..26dde70 100644 --- a/ambiq-hal/Cargo.lock +++ b/ambiq-hal/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "0.7.15" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -31,9 +31,9 @@ dependencies = [ "cortex-m", "cortex-m-rt", "defmt", - "embedded-hal", + "embedded-hal 1.0.0", "embedded-time", - "nb 1.0.0", + "nb 1.1.0", "paste", "rtcc", "ufmt", @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi", ] @@ -71,9 +71,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bare-metal" @@ -86,11 +86,11 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.59.1" +version = "0.59.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453c49e5950bb0eb63bb3df640e31618846c89d5b7faa54040d76e98e0134375" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "clap", @@ -120,28 +120,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bitvec" -version = "0.19.5" +name = "bitflags" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "cc" -version = "1.0.70" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" [[package]] name = "cexpr" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db507a7679252d2276ed0dd8113c6875ec56d3089f9225b2b42c30cc1f8e5c89" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ "nom", ] @@ -154,19 +148,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ - "num-integer", "num-traits", ] [[package]] name = "clang-sys" -version = "1.2.2" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10612c0ec0e0a1ff0e97980647cb058a6e7aedb913d01d009c406b8b7d0b26ee" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", @@ -175,13 +168,13 @@ dependencies = [ [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim", "textwrap", "unicode-width", @@ -190,21 +183,21 @@ dependencies = [ [[package]] name = "cortex-m" -version = "0.7.3" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac919ef424449ec8c08d515590ce15d9262c0ca5f0da5b0c901e971a3b783b3" +checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" dependencies = [ "bare-metal", "bitfield", - "embedded-hal", + "embedded-hal 0.2.7", "volatile-register", ] [[package]] name = "cortex-m-rt" -version = "0.7.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069533b58e25b635fac881eb6556616bd8f83a3e0ffe2b4b9619289ed14d465e" +checksum = "ee84e813d593101b1723e13ec38b6ab6abbdbaaa4546553f5395ed274079ddb1" dependencies = [ "cortex-m-rt-macros", ] @@ -217,48 +210,63 @@ checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "defmt" -version = "0.3.0" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62fb5df4d2b06a2dbf6ba26b49031f5f45f1aafdfca4b9259719466d362f34a0" +checksum = "a99dd22262668b887121d4672af5a64b238f026099f1a2a1b322066c9ecfe9e0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "defmt-macros", ] [[package]] name = "defmt-macros" -version = "0.3.0" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dede7fc0d15f4b8e15f3f023aefe6806066d7eb382123981e106fba05b35c5a3" +checksum = "e3a9f309eff1f79b3ebdf252954d90ae440599c26c2c553fe87a2d17195f2dcb" dependencies = [ "defmt-parser", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 2.0.66", ] [[package]] name = "defmt-parser" -version = "0.3.0" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff4a5fefe330e8d7f31b16a318f9ce81000d8e35e69b93eae154d16d2278f70f" +dependencies = [ + "thiserror", +] + +[[package]] +name = "either" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d1ce010e1a51aef925c98f12ed81a4e0e96ce0185a87c33f1b3b9c8f20749c7" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "embedded-hal" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36cfb62ff156596c892272f3015ef952fe1525e85261fa3a7f327bd6b384ab9" +checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" dependencies = [ "nb 0.1.3", "void", ] +[[package]] +name = "embedded-hal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89" + [[package]] name = "embedded-time" version = "0.12.1" @@ -270,9 +278,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.8.4" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", "humantime", @@ -282,22 +290,26 @@ dependencies = [ ] [[package]] -name = "fs_extra" -version = "1.2.0" +name = "errno" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] [[package]] -name = "funty" -version = "1.1.0" +name = "fs_extra" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hermit-abi" @@ -308,6 +320,15 @@ dependencies = [ "libc", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys", +] + [[package]] name = "humantime" version = "2.1.0" @@ -328,34 +349,43 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.103" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" -version = "0.7.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "winapi", + "windows-targets", ] [[package]] -name = "log" +name = "linux-raw-sys" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if", -] +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.3.4" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "nb" @@ -363,25 +393,23 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" dependencies = [ - "nb 1.0.0", + "nb 1.1.0", ] [[package]] name = "nb" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" +checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "nom" -version = "6.2.1" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c5c51b9083a3c620fa67a2a635d1ce7d95b897e957d6b28ff9a5da960a103a6" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ - "bitvec", - "funty", "memchr", - "version_check", + "minimal-lexical", ] [[package]] @@ -408,19 +436,18 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.42" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -440,18 +467,24 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + [[package]] name = "paste" -version = "1.0.5" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "peeking_take_while" @@ -468,7 +501,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -483,41 +516,41 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - [[package]] name = "proc-macro2" -version = "1.0.29" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.9" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] -name = "radium" -version = "0.5.3" +name = "regex" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] [[package]] -name = "regex" -version = "1.4.6" +name = "regex-automata" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -526,15 +559,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rtcc" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3623619ce77c09a7d87cf7c61c5c887b9c7dee8805f66af6c4aa5824be4d9930" +checksum = "95973c3a0274adc4f3c5b70d2b5b85618d6de9559a6737d3293ecae9a2fc0839" dependencies = [ "chrono", ] @@ -554,6 +587,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "semver" version = "0.9.0" @@ -571,9 +617,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "shlex" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "strsim" @@ -583,26 +629,31 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.77" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5239bc68e0fef57495900cfea4e8dc75596d9a319d7e16b1e0a440d24e6fe0a0" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] -name = "tap" -version = "1.0.1" +name = "syn" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] [[package]] name = "termcolor" -version = "1.1.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -616,27 +667,45 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "ufmt" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7ecea7ef79d3f8f878eee614afdf5256475c63ad76139d4da6125617c784a0" +checksum = "1a64846ec02b57e9108d6469d98d1648782ad6bb150a95a9baac26900bbeab9d" dependencies = [ - "proc-macro-hack", "ufmt-macros", "ufmt-write", ] [[package]] name = "ufmt-macros" -version = "0.1.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed813e34a2bfa9dc58ee2ed8c8314d25e6d70c911486d64b8085cb695cfac069" +checksum = "d337d3be617449165cb4633c8dece429afd83f84051024079f97ad32a9663716" dependencies = [ - "proc-macro-hack", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -646,16 +715,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" [[package]] -name = "unicode-width" -version = "0.1.9" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "unicode-width" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "vcell" @@ -671,9 +740,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "void" @@ -683,20 +752,23 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "volatile-register" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" +checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" dependencies = [ "vcell", ] [[package]] name = "which" -version = "3.1.1" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" dependencies = [ - "libc", + "either", + "home", + "once_cell", + "rustix", ] [[package]] @@ -717,11 +789,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys", ] [[package]] @@ -731,7 +803,74 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "wyz" -version = "0.2.0" +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/ambiq-hal/Cargo.toml b/ambiq-hal/Cargo.toml index 41c2b78..ba2b0a1 100644 --- a/ambiq-hal/Cargo.toml +++ b/ambiq-hal/Cargo.toml @@ -10,16 +10,16 @@ repository = "https://github.com/gauteh/ambiq-rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -embedded-hal = { version = "0.2.6", features = [ "unproven" ] } +embedded-hal = { version = "1" } cortex-m = "0.7" cortex-m-rt = { version = "0.7", optional = true } -paste = "1.0.5" -nb = "1.0.0" -ufmt = "0.1.0" +paste = "1" +nb = "1" +ufmt = "0.2" defmt = "0.3" -embedded-time = "0.12.1" -chrono = { version = "0.4.19", default-features = false } -rtcc = "0.3.0" +embedded-time = "0.12" +chrono = { version = "0.4", default-features = false } +rtcc = "0.3" [dependencies.ambiq-hal-sys] path = "../ambiq-hal-sys" diff --git a/ambiq-hal/src/delay.rs b/ambiq-hal/src/delay.rs index 5004424..b7bf524 100644 --- a/ambiq-hal/src/delay.rs +++ b/ambiq-hal/src/delay.rs @@ -10,7 +10,7 @@ use cortex_m::peripheral::SYST; use crate::clock; use crate::time::Hertz; -use hal::blocking::delay::{DelayMs, DelayUs}; +use hal::delay::DelayNs; use pac::CLKGEN; /// System timer (SysTick) as a delay provider @@ -48,30 +48,12 @@ impl Delay { } } -impl DelayMs for Delay { - fn delay_ms(&mut self, ms: u32) { - self.delay_us(ms * 1_000); - } -} - -impl DelayMs for Delay { - fn delay_ms(&mut self, ms: u16) { - self.delay_ms(ms as u32); - } -} - -impl DelayMs for Delay { - fn delay_ms(&mut self, ms: u8) { - self.delay_ms(ms as u32); - } -} - -impl DelayUs for Delay { - fn delay_us(&mut self, us: u32) { +impl DelayNs for Delay { + fn delay_ns(&mut self, ns: u32) { // The SysTick Reload Value register supports values between 1 and 0x00FFFFFF. const MAX_RVR: u32 = 0x00FF_FFFF; - let mut total_rvr = us * (self.sysclock.0 / 1_000_000); + let mut total_rvr = ns * (self.sysclock.0 / 1_000_000_000); while total_rvr != 0 { let current_rvr = if total_rvr <= MAX_RVR { @@ -94,18 +76,6 @@ impl DelayUs for Delay { } } -impl DelayUs for Delay { - fn delay_us(&mut self, us: u16) { - self.delay_us(us as u32) - } -} - -impl DelayUs for Delay { - fn delay_us(&mut self, us: u8) { - self.delay_us(us as u32) - } -} - #[cfg(feature = "ambiq-sdk")] pub use flash::FlashDelay; @@ -167,8 +137,8 @@ pub mod flash { } } - impl DelayUs for FlashDelay { - fn delay_us(&mut self, us: u32) { + impl DelayNs for FlashDelay { + fn delay_ns(&mut self, ns: u32) { // Get clock frequency. let clkgen = unsafe { &*CLKGEN::ptr() }; let sysclock = match clkgen.cctrl.read().coresel().variant() { @@ -182,30 +152,11 @@ pub mod flash { } }; - let cycles = us * (sysclock.0 / 3_000_000); + let cycles = ns * (sysclock.0 / 3_000_000_000); unsafe { halc::am_hal_flash_delay(cycles); } } } - - impl DelayUs for FlashDelay { - fn delay_us(&mut self, us: u16) { - self.delay_us(us as u32) - } - } - - impl DelayUs for FlashDelay { - fn delay_us(&mut self, us: u8) { - self.delay_us(us as u32) - } - } - - impl DelayMs for FlashDelay where T: Into { - fn delay_ms(&mut self, us: T) { - let us = us.into(); - DelayUs::::delay_us(self, us * 1000); - } - } } From 1e418661135a600cd4d44f6c6ec9c7d0f67a4af5 Mon Sep 17 00:00:00 2001 From: Gaute Hope Date: Mon, 17 Jun 2024 09:34:44 +0200 Subject: [PATCH 2/3] pin+watchdog: eh1 --- ambiq-hal/src/gpio/pin.rs | 83 +++++++++++++++++++++------------------ ambiq-hal/src/lib.rs | 3 +- ambiq-hal/src/watchdog.rs | 8 ++-- 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/ambiq-hal/src/gpio/pin.rs b/ambiq-hal/src/gpio/pin.rs index 34df0d8..7007e5e 100644 --- a/ambiq-hal/src/gpio/pin.rs +++ b/ambiq-hal/src/gpio/pin.rs @@ -1,8 +1,7 @@ use super::gpio_cfg; -use crate::hal::digital::v2::{InputPin, IoPin, OutputPin, ToggleableOutputPin}; +use crate::hal::digital::{InputPin, OutputPin, StatefulOutputPin, ErrorType}; use core::convert::Infallible; use core::marker::ConstParamTy; -use embedded_hal::digital::v2::PinState; use paste::paste; /// The drive strength is controlled by setting registers: @@ -157,25 +156,6 @@ where } } -impl IoPin, Pin> - for Pin -where - Pin: PinCfg, - Pin: PinCfg, - Pin: PinCfg, -{ - type Error = Infallible; - - fn into_input_pin(self) -> Result, Self::Error> { - Ok(self.into_input()) - } - - fn into_output_pin(self, state: PinState) -> Result, Self::Error> { - write_state(P, matches!(state, PinState::High)); - Ok(self.into_push_pull_output()) - } -} - impl Pin where Pin: PinCfg, @@ -224,12 +204,15 @@ where } } +impl ErrorType for Pin +{ + type Error = Infallible; +} + impl OutputPin for Pin where Pin: PinCfg, { - type Error = Infallible; - fn set_low(&mut self) -> Result<(), Infallible> { write_state(P, false); Ok(()) @@ -245,8 +228,6 @@ impl OutputPin for Pin where Pin: PinCfg, { - type Error = Infallible; - fn set_low(&mut self) -> Result<(), Infallible> { write_state(P, false); Ok(()) @@ -262,13 +243,11 @@ impl InputPin for Pin where Pin: PinCfg, { - type Error = Infallible; - - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { self.is_high().map(|b| !b) } - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(read_input_state(P)) } } @@ -277,13 +256,11 @@ impl InputPin for Pin where Pin: PinCfg, { - type Error = Infallible; - - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { self.is_high().map(|b| !b) } - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(read_input_state(P)) } } @@ -339,11 +316,26 @@ fn toggle_state(P: usize) { }); } -impl ToggleableOutputPin for Pin +impl StatefulOutputPin for Pin where Pin: PinCfg, { - type Error = Infallible; + fn is_set_high(&mut self) -> Result { + let mask: u32 = 0b1u32 << P % 32; + + let reg = unsafe { + match P { + 0..=31 => (*pac::GPIO::ptr()).wta.as_ptr(), + _ => (*pac::GPIO::ptr()).wtb.as_ptr(), + } + }; + + Ok(unsafe { *reg & mask != 0 }) + } + + fn is_set_low(&mut self) -> Result { + self.is_set_high().map(|b| !b) + } fn toggle(&mut self) -> Result<(), Infallible> { toggle_state(P); @@ -352,11 +344,26 @@ where } } -impl ToggleableOutputPin for Pin +impl StatefulOutputPin for Pin where - Pin: PinCfg, + Pin: PinCfg, { - type Error = Infallible; + fn is_set_high(&mut self) -> Result { + let mask: u32 = 0b1u32 << P % 32; + + let reg = unsafe { + match P { + 0..=31 => (*pac::GPIO::ptr()).wta.as_ptr(), + _ => (*pac::GPIO::ptr()).wtb.as_ptr(), + } + }; + + Ok(unsafe { *reg & mask != 0 }) + } + + fn is_set_low(&mut self) -> Result { + self.is_set_high().map(|b| !b) + } fn toggle(&mut self) -> Result<(), Infallible> { toggle_state(P); diff --git a/ambiq-hal/src/lib.rs b/ambiq-hal/src/lib.rs index e175550..54ce0ad 100644 --- a/ambiq-hal/src/lib.rs +++ b/ambiq-hal/src/lib.rs @@ -50,8 +50,7 @@ pub mod iom; pub use iom::{i2c, spi}; pub mod prelude { - pub use hal::prelude::*; - pub use hal::digital::v2::{InputPin, OutputPin, ToggleableOutputPin}; + pub use hal::digital::{InputPin, OutputPin, StatefulOutputPin}; #[cfg(feature = "ambiq-sdk")] pub use halc; diff --git a/ambiq-hal/src/watchdog.rs b/ambiq-hal/src/watchdog.rs index e889107..3903f6a 100644 --- a/ambiq-hal/src/watchdog.rs +++ b/ambiq-hal/src/watchdog.rs @@ -1,5 +1,4 @@ use crate::pac::{wdt, WDT}; -use embedded_hal::watchdog; pub struct Watchdog { wdt: WDT, @@ -27,7 +26,7 @@ impl Watchdog { /// Start the watchdog. pub fn start(&mut self) { self.wdt.cfg.modify(|_, w| w.wdten().set_bit()); - watchdog::Watchdog::feed(self); + self.feed(); // Seems like there's a HW-bug which requires this (from C-HAL). Should just read `0`. self.wdt.rstrt.read().bits(); @@ -44,12 +43,11 @@ impl Watchdog { pub fn halt(&mut self) { self.wdt.cfg.modify(|_, w| w.wdten().clear_bit()); } -} -impl watchdog::Watchdog for Watchdog { - fn feed(&mut self) { + pub fn feed(&mut self) { self.wdt .rstrt .write(|w| w.rstrt().variant(wdt::rstrt::RSTRT_A::KEYVALUE)); } } + From 2d806db93adb3e3d09268a4ed64dd06b65ffa923 Mon Sep 17 00:00:00 2001 From: Gaute Hope Date: Mon, 17 Jun 2024 09:39:53 +0200 Subject: [PATCH 3/3] i2c: move to eh1 --- ambiq-hal/src/iom/i2c.rs | 71 ++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/ambiq-hal/src/iom/i2c.rs b/ambiq-hal/src/iom/i2c.rs index 5c54685..ffe3e5d 100644 --- a/ambiq-hal/src/iom/i2c.rs +++ b/ambiq-hal/src/iom/i2c.rs @@ -12,7 +12,7 @@ use core::ops::Deref; use core::ptr; #[allow(unused_imports)] use defmt::{debug, error, info, trace, warn}; -use embedded_hal::blocking::i2c::*; +use embedded_hal::i2c::{self, SevenBitAddress, Operation}; use crate::gpio::{self, Mode}; use crate::delay::FlashDelay; @@ -286,48 +286,10 @@ where r } -} - -impl Drop for I2c -where - IOM: Deref, - Sda: SdaPin, - Scl: SclPin, -{ - fn drop(&mut self) { - unsafe { - halc::am_hal_iom_uninitialize(self.phiom); - self.phiom = ptr::null_mut(); - } - } -} -impl Write for I2c -where - IOM: Deref, - Sda: SdaPin, - Scl: SclPin, - gpio::pin::Pin: gpio::pin::PinCfg, - gpio::pin::Pin: gpio::pin::PinCfg, -{ - type Error = I2cError; - fn write(&mut self, addr: u8, output: &[u8]) -> Result<(), Self::Error> { - self.write(addr, output, false) - } -} -impl Read for I2c -where - IOM: Deref, - Sda: SdaPin, - Scl: SclPin, - gpio::pin::Pin: gpio::pin::PinCfg, - gpio::pin::Pin: gpio::pin::PinCfg, -{ - type Error = I2cError; - - fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { + fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), I2cError> { trace!( "i2c: reading: addr = 0x{:02x}, len = {}", address, @@ -365,7 +327,21 @@ where } } -impl WriteRead for I2c +impl Drop for I2c +where + IOM: Deref, + Sda: SdaPin, + Scl: SclPin, +{ + fn drop(&mut self) { + unsafe { + halc::am_hal_iom_uninitialize(self.phiom); + self.phiom = ptr::null_mut(); + } + } +} + +impl i2c::I2c for I2c where IOM: Deref, Sda: SdaPin, @@ -373,7 +349,18 @@ where gpio::pin::Pin: gpio::pin::PinCfg, gpio::pin::Pin: gpio::pin::PinCfg, { - type Error = I2cError; + fn transaction( + &mut self, + address: SevenBitAddress, + operations: &mut [Operation<'_>] + ) -> Result<(), Self::Error> { + for op in operations { + match op { + Operation::Read(buf) => self.read(address, buf)?, + Operation::Write(buf) => self.write(address, buf, false)?, + } + } + } fn write_read( &mut self,