From: Patrick O'Doherty Date: Sun, 20 Sep 2020 17:51:31 +0000 (-0700) Subject: Initial port to Feather M4 X-Git-Url: https://git.patrickod.com/tor.noisebridge.net/patch?a=commitdiff_plain;h=2c5a6ce701efb11787525a42b6ced9957e32e6ca;p=keywing-rs.git Initial port to Feather M4 Changes: * Update the SPI and i2c bus initialization to use the handy feather_m4 hal helper methods. * Hack out some timer code in the invalid key handler due to differences in timer/delay API to return to later. * update memory.x referencing the atsamd feather_m4 board definition & reserving 1KB for panic dumping --- diff --git a/.gitmodules b/.gitmodules index 8971b25..415292f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "ili9341-rs"] path = ili9341-rs url = git@github.com:jamesmunns/ili9341-rs.git -[submodule "nrf-hal"] - path = nrf-hal - url = git@github.com:jamesmunns/nrf-hal.git [submodule "bbq10kbd"] path = bbq10kbd url = https://github.com/jamesmunns/bbq10kbd diff --git a/keywing/.cargo/config b/keywing/.cargo/config index 5673fa9..fd7ff15 100644 --- a/keywing/.cargo/config +++ b/keywing/.cargo/config @@ -1,9 +1,9 @@ +# vim:ft=toml: +[target.thumbv7em-none-eabihf] +runner = 'arm-none-eabi-gdb' + [build] target = "thumbv7em-none-eabihf" - -[target.thumbv7em-none-eabihf] -# runner = 'gdbgui -g arm-none-eabi-gdb --gdb-args="-command=debug.gdb"' -runner = "arm-none-eabi-gdb -tui -q -x debug.gdb" rustflags = [ - "-C", "link-arg=-Tlink.x", + "-C", "link-arg=-Tlink.x", ] diff --git a/keywing/Cargo.lock b/keywing/Cargo.lock index 56bb412..7761169 100644 --- a/keywing/Cargo.lock +++ b/keywing/Cargo.lock @@ -2,19 +2,47 @@ # It is not intended for manual editing. [[package]] name = "aligned" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "as-slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "as-slice 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "as-slice" -version = "0.1.0" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", - "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", + "stable_deref_trait 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atsamd-hal" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atsamd51j19a 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-m 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "embedded-hal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "nb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "paste 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atsamd51j19a" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-m 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-m-rt 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -29,50 +57,47 @@ dependencies = [ name = "bbq10kbd" version = "0.1.0" dependencies = [ - "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "embedded-hal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "byteorder" -version = "1.3.2" +name = "bitfield" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "cast" -version = "0.2.3" +name = "byteorder" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "cortex-m" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aligned 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "aligned 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", "volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cortex-m-rt" -version = "0.6.10" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cortex-m-rt-macros 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-m-rt-macros 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cortex-m-rt-macros" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" 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)", - "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -80,25 +105,28 @@ name = "embedded-graphics" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "embedded-hal" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "nb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "fpa" -version = "0.1.0" +name = "feather_m4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "atsamd-hal 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-m 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-m-rt 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "embedded-hal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "nb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -106,7 +134,7 @@ name = "generic-array" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -114,7 +142,7 @@ name = "generic-array" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -122,17 +150,18 @@ name = "hash32" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heapless" -version = "0.5.1" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "as-slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "as-slice 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", "hash32 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "stable_deref_trait 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -140,101 +169,88 @@ name = "ili9341" version = "0.3.0" dependencies = [ "embedded-graphics 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "embedded-hal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "nb" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "nrf-hal-common" -version = "0.10.0" +name = "keywing" +version = "0.1.0" dependencies = [ - "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fpa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "nrf52840-pac 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bbq10kbd 0.1.0", + "cortex-m 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-m-rt 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "embedded-graphics 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "embedded-hal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "feather_m4 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "heapless 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "ili9341 0.3.0", + "nb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "panic-persist 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rtt-target 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "nrf52840-hal" -version = "0.10.0" +name = "nb" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "nrf-hal-common 0.10.0", - "nrf52840-pac 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "nb 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "nrf52840-pac" -version = "0.9.0" +name = "nb" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cortex-m-rt 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "panic-persist" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-m 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "proc-macro2" -version = "1.0.6" +name = "paste" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "paste-impl 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "quote" -version = "1.0.2" +name = "paste-impl" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "r0" -version = "0.2.2" +name = "proc-macro-hack" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "rand" -version = "0.5.6" +name = "proc-macro2" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rand_core" -version = "0.3.1" +name = "quote" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rand_core" -version = "0.4.2" +name = "r0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -244,12 +260,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rtt-target" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-m 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "ufmt-write 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -275,39 +290,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "stable_deref_trait" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "1.0.8" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" 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)", -] - -[[package]] -name = "tiny-nrf52" -version = "0.1.0" -dependencies = [ - "bbq10kbd 0.1.0", - "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cortex-m-rt 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "embedded-graphics 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "heapless 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ili9341 0.3.0", - "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "nrf52840-hal 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "panic-persist 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rtt-target 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "typenum" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -317,7 +315,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -339,41 +337,42 @@ dependencies = [ ] [metadata] -"checksum aligned 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a316c7ea8e1e9ece54862c992def5a7ac14de9f5832b69d71760680efeeefa" -"checksum as-slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "293dac66b274fab06f95e7efb05ec439a6b70136081ea522d270bc351ae5bb27" +"checksum aligned 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c19796bd8d477f1a9d4ac2465b464a8b1359474f06a96bb3cda650b4fca309bf" +"checksum as-slice 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "37dfb65bc03b2bc85ee827004f14a6817e04160e3b1a28931986a666a9290e70" +"checksum atsamd-hal 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a845093b449700f878b8a91323e10307577e28f29f37c859645eaba2e655a60f" +"checksum atsamd51j19a 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f3710f797630bb6fd7ab101e057e9a9f43342e86727867b03c76dfd42c20a05b" "checksum bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" -"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" -"checksum cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2954942fbbdd49996704e6f048ce57567c3e1a4e2dc59b41ae9fde06a01fc763" -"checksum cortex-m-rt 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "17805910e3ecf029bdbfcc42b7384d9e3d9e5626153fa810002c1ef9839338ac" -"checksum cortex-m-rt-macros 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2a6dc359ebb215c4924bffacfe46a8f02ef80fe2071bba1635a2ded42b40f936" +"checksum bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" +"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +"checksum cortex-m 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2be99930c99669a74d986f7fd2162085498b322e6daae8ef63a97cc9ac1dc73c" +"checksum cortex-m-rt 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "980c9d0233a909f355ed297ef122f257942de5e0a2cb1c39f60684b65bcb90fb" +"checksum cortex-m-rt-macros 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4717562afbba06e760d34451919f5c3bf3ac15c7bb897e8b04862a7428378647" "checksum embedded-graphics 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "40a69991ceb896bd4810a0cf2bcc46fc94b7860573c71f965d8e5b3d66942fed" -"checksum embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ee4908a155094da7723c2d60d617b820061e3b4efcc3d9e293d206a5a76c170b" -"checksum fpa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f074479d683e5a8fd0bf1251d0a5d91b0d9178b867b44962191ed0eaaf8d4009" +"checksum embedded-hal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fa998ce59ec9765d15216393af37a58961ddcefb14c753b4816ba2191d865fcb" +"checksum feather_m4 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96671f623dfdb988a95695a70ac1d02cfbbc6e6552a3c5fdf2791e8855100e2c" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0ed1e761351b56f54eb9dcd0cfaca9fd0daecf93918e1cfc01c8a3d26ee7adcd" "checksum hash32 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d4041af86e63ac4298ce40e5cca669066e75b6f1aa3390fe2561ffa5e1d9f4cc" -"checksum heapless 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f339aa7d51777fc0af6aa7cbeb277dfc6e6c029cbdeda48d0fbb92c2337f0e69" -"checksum nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b1411551beb3c11dedfb0a90a0fa256b47d28b9ec2cdff34c25a2fa59e45dbdc" -"checksum nrf52840-hal 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aab4c41abc02fcefbdbedfa773d213302bc00c57a0b2237c6b5bf0456da10d3" -"checksum nrf52840-pac 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1b780a5afd2621774652f28c82837f6aa6d19cf0ad71c734fc1fe53298a2d73" +"checksum heapless 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "73a8a2391a3bc70b31f60e7a90daa5755a360559c0b6b9c5cfc0fee482362dc0" +"checksum nb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" +"checksum nb 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" "checksum panic-persist 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd2e692a5954e3eb0c16f5dbaa75c4332a78d85851521f138c04ad95d6f5ee42" -"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 paste 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" +"checksum paste-impl 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" +"checksum proc-macro-hack 0.5.18 (registry+https://github.com/rust-lang/crates.io-index)" = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" +"checksum proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "36e28516df94f3dd551a587da5357459d9b36d945a7c37c3557928c1c2ff2a2c" +"checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" "checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" -"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum rtt-target 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58b1f36984bbcf227044b3b7af1de14a6ebe51b9d21cd856a3d5ba41c70ec191" +"checksum rtt-target 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0869b4c5b6a6d8c5583fc473f9eb3423a170f77626b8c8a7fb18eddcda5770e2" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" -"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" -"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +"checksum stable_deref_trait 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +"checksum syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b" +"checksum typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" "checksum ufmt-write 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" "checksum vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "876e32dcadfe563a4289e994f7cb391197f362b6315dc45e8ba4aa6f564a4b3c" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" diff --git a/keywing/Cargo.toml b/keywing/Cargo.toml index e1f5723..b5fdcac 100644 --- a/keywing/Cargo.toml +++ b/keywing/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "tiny-nrf52" +name = "keywing" version = "0.1.0" -authors = ["James Munns "] +authors = ["Patrick O'Doherty "] edition = "2018" [dependencies] @@ -21,15 +21,14 @@ path = "../ili9341-rs" version = "0.1.0" path = "../bbq10kbd" -[dependencies.nrf52840-hal] -version = "0.10.0" -features = ["rt"] - [dependencies.panic-persist] version = "0.2.1" default-features = false features = ["utf8"] +[dependencies.feather_m4] +version = "0.5.0" + [profile.dev] lto = true panic = "abort" @@ -39,12 +38,6 @@ codegen-units = 1 opt-level = 0 [profile.release] -lto = true -panic = "abort" -debug = true -incremental = false -codegen-units = 1 -opt-level = 's' - -[patch.crates-io] -nrf-hal-common = { path = "../nrf-hal/nrf-hal-common" } +debug = true +lto = true +opt-level = "s" \ No newline at end of file diff --git a/keywing/Embed.toml b/keywing/Embed.toml deleted file mode 100644 index 918f48c..0000000 --- a/keywing/Embed.toml +++ /dev/null @@ -1,46 +0,0 @@ -[probe] -# The index of the probe in the connected probe list. -probe_index = 0 -# The protocol to be used for communicating with the target. -protocol = "Swd" -# The speed in kHz of the data link to the target. -# speed = 1337 - -[flashing] -# Whether or not the target should be flashed. -enabled = true -# Whether or not the target should be halted after flashing. -halt_afterwards = false -# Whether or not bytes erased but not rewritten with data from the ELF -# should be restored with their contents before erasing. -restore_unwritten_bytes = false -# The path where an SVG of the assembled flash layout should be written to. -# flash_layout_output_path = "out.svg" - -[general] -# The chip name of the chip to be debugged. -chip = "nRF52840_xxAA" -# A list of chip descriptions to be loaded during runtime. -chip_descriptions = [] -# The default log level to be used. -log_level = "Warn" - -[rtt] -# Whether or not an RTTUI should be opened after flashing. -# This is exclusive and cannot be used with GDB at the moment. -enabled = true -# A list of channel associations to be displayed. If left empty, all channels are displayed. -channels = [ - # { up = 0, down = 0, name = "name" } -] -# The duration in ms for which the logger should retry to attach to RTT. -timeout = 3000 -# Whether timestamps in the RTTUI are enabled -show_timestamps = true - -[gdb] -# Whether or not a GDB server should be opened after flashing. -# This is exclusive and cannot be used with RTT at the moment. -enabled = false -# The connection string in host:port format wher the GDB server will open a socket. -# gdb_connection_string diff --git a/keywing/memory.x b/keywing/memory.x index 46f1278..bbbe065 100644 --- a/keywing/memory.x +++ b/keywing/memory.x @@ -1,10 +1,13 @@ MEMORY { - /* NOTE K = KiBi = 1024 bytes */ - FLASH : ORIGIN = 0x00000000, LENGTH = 1M - RAM : ORIGIN = 0x20000000, LENGTH = 255K - PANDUMP: ORIGIN = 0x2003FC00, LENGTH = 1K + /* Leave 16k for the default bootloader on the Feather M4 */ + FLASH (rx) : ORIGIN = 0x00000000 + 16K, LENGTH = 512K - 16K + /* Usually 192K RAM. Reserve 1K at the end for storing panic dumps */ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 191K + PANDUMP (rw) : ORIGIN = 0x20000000 + 191K, LENGTH = 1K } +_stack_start = ORIGIN(RAM) + LENGTH(RAM); _panic_dump_start = ORIGIN(PANDUMP); -_panic_dump_end = ORIGIN(PANDUMP) + LENGTH(PANDUMP); +_panic_dump_end = ORIGIN(PANDUMP) + LENGTH(PANDUMP); + diff --git a/keywing/src/main.rs b/keywing/src/main.rs index 2397fa8..28841c1 100644 --- a/keywing/src/main.rs +++ b/keywing/src/main.rs @@ -7,15 +7,16 @@ use panic_persist as _; // Used to set the program entry point use cortex_m_rt::entry; -// Provides definitions for our development board -use nrf52840_hal::{ - gpio::{p0::Parts as P0Parts, p1::Parts as P1Parts, Level}, - prelude::*, - spim::{Frequency as SpimFrequency, Pins as SpimPins, MODE_0}, - target::Peripherals, - twim::{Frequency as TwimFrequency, Pins as TwimPins}, - Clocks, Rng, Spim, Timer, Twim, -}; +extern crate feather_m4 as hal; + +use hal::prelude::*; +use hal::clock::GenericClockController; +use hal::pac::{CorePeripherals,Peripherals}; +use hal::trng::Trng; +use hal::delay::Delay; +use hal::Pins; +use hal::{i2c_master,spi_master}; +use hal::time::U32Ext; use rtt_target::{rprintln, rtt_init_print}; @@ -41,11 +42,19 @@ fn main() -> ! { } fn inner_main() -> Result<(), &'static str> { - let board = Peripherals::take().ok_or("Error getting board!")?; - let mut timer = Timer::new(board.TIMER0); - let mut delay = Timer::new(board.TIMER1); - let mut _rng = Rng::new(board.RNG); - let _clocks = Clocks::new(board.CLOCK).enable_ext_hfosc(); + let mut peripherals = Peripherals::take().ok_or("Error getting board!")?; + let mut _pins = Pins::new(peripherals.PORT); + let _core = CorePeripherals::take().unwrap(); + + let mut _rng: Trng = Trng::new(&mut peripherals.MCLK, peripherals.TRNG); + let mut _clocks = GenericClockController::with_external_32kosc( + peripherals.GCLK, + &mut peripherals.MCLK, + &mut peripherals.OSC32KCTRL, + &mut peripherals.OSCCTRL, + &mut peripherals.NVMCTRL, + ); + let mut delay = Delay::new(_core.SYST, &mut _clocks); // use ChannelMode::NoBlockS rtt_init_print!(NoBlockSkip, 4096); @@ -56,52 +65,45 @@ fn inner_main() -> Result<(), &'static str> { rprintln!("Clean boot!"); } - let p0 = P0Parts::new(board.P0); - let p1 = P1Parts::new(board.P1); - - let kbd_lcd_reset = p1.p1_08; // GPIO5, D5 - let _stm_cs = p0.p0_07; // GPIO6, D6, - let lcd_cs = p0.p0_26; // GPIO9, D9, - let lcd_dc = p0.p0_27; // GPIO10, D10 - - let kbd_sda = p0.p0_12.into_floating_input().degrade(); - let kbd_scl = p0.p0_11.into_floating_input().degrade(); - - let kbd_i2c = Twim::new( - board.TWIM0, - TwimPins { - sda: kbd_sda, - scl: kbd_scl, - }, - TwimFrequency::K100, + let kbd_lcd_reset = _pins.d5; + let _stm_cs = _pins.d6; + let lcd_cs = _pins.d9; + let lcd_dc = _pins.d10; + + // i2c keyboard interface + // kbd SDA = D12 + // kbd SCL = D11 + // FREQ 100KHZ + let kbd_i2c = i2c_master( + &mut _clocks, + 100u32.khz(), + peripherals.SERCOM2, + &mut peripherals.MCLK, + _pins.sda, + _pins.scl, + &mut _pins.port ); let mut kbd = Bbq10Kbd::new(kbd_i2c); - // Pull the neopixel lines low so noise doesn't make it turn on spuriously - let _keywing_neopixel = p0.p0_06.into_push_pull_output(Level::Low); // GPIO11, D11 - let _feather_neopixel = p0.p0_16.into_push_pull_output(Level::Low); - - let spim = Spim::new( - board.SPIM3, - SpimPins { - sck: p0.p0_14.into_push_pull_output(Level::Low).degrade(), - miso: Some(p0.p0_15.into_floating_input().degrade()), - mosi: Some(p0.p0_13.into_push_pull_output(Level::Low).degrade()), - }, - SpimFrequency::M32, - MODE_0, - 0x00, + let lcd_spi = spi_master( + &mut _clocks, + 32u32.mhz(), + peripherals.SERCOM1, + &mut peripherals.MCLK, + _pins.sck, + _pins.mosi, + _pins.miso, + &mut _pins.port ); let mut lcd = Ili9341::new_spi( - spim, - lcd_cs.into_push_pull_output(Level::High), - lcd_dc.into_push_pull_output(Level::High), - kbd_lcd_reset.into_push_pull_output(Level::High), + lcd_spi, + lcd_cs.into_push_pull_output(&mut _pins.port), + lcd_dc.into_push_pull_output(&mut _pins.port), + kbd_lcd_reset.into_push_pull_output(&mut _pins.port), &mut delay, - ) - .unwrap(); + ).unwrap(); lcd.set_orientation(Orientation::Landscape).unwrap(); @@ -125,7 +127,7 @@ fn inner_main() -> Result<(), &'static str> { rprintln!("Vers: {:?}", vers); kbd.sw_reset().unwrap(); - timer.delay_ms(10u8); + delay.delay_ms(10u8); let vers = kbd.get_version().unwrap(); @@ -215,12 +217,12 @@ fn inner_main() -> Result<(), &'static str> { } KeyRaw::Invalid => { if let Some(buf) = fbuffy.inner() { - timer.start(1_000_000u32); + // timer.start(1_000_000u32); lcd.draw_raw(0, 0, 319, 239, buf).map_err(|_| "bad buffy")?; - let done = timer.read(); - rprintln!("Drew in {}ms.", done / 1000); + // let done = timer.read(); + // rprintln!("Drew in {}ms.", done / 1000); } else { - timer.delay_ms(38u8); + delay.delay_ms(38u8); } } _ => {} diff --git a/nrf-hal b/nrf-hal deleted file mode 160000 index f98fe76..0000000 --- a/nrf-hal +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f98fe76b4b0d43a8a542c0002ce6b2568d9f4070 diff --git a/shell.nix b/shell.nix index 19b7c15..1c5dc56 100644 --- a/shell.nix +++ b/shell.nix @@ -1,6 +1,4 @@ let - rust-version = "1.46.0"; - nixpkgs = fetchGit { url = "https://github.com/patrickod/nixpkgs.git"; rev = "8bb6ca5f0a93bb0b9264b50a8c56431c7c7cc591"; @@ -21,8 +19,7 @@ let in pkgs.mkShell { - name = "rust-dev"; - nativeBuildInputs = with pkgs; [ + buildInputs = with pkgs; [ (rustChannels.stable.rust.override { targets = targets; extensions = [