]> patrickod personal git archive - keywing-rs.git/commitdiff
Not exactly initial commit
authorJames Munns <james.munns@ferrous-systems.com>
Tue, 26 May 2020 21:18:32 +0000 (23:18 +0200)
committerJames Munns <james.munns@ferrous-systems.com>
Tue, 26 May 2020 21:18:32 +0000 (23:18 +0200)
12 files changed:
.gitmodules [new file with mode: 0644]
ili9341-rs [new submodule]
keywing/.cargo/config [new file with mode: 0644]
keywing/.gitignore [new file with mode: 0644]
keywing/Cargo.lock [new file with mode: 0644]
keywing/Cargo.toml [new file with mode: 0644]
keywing/Embed.toml [new file with mode: 0644]
keywing/debug.gdb [new file with mode: 0644]
keywing/memory.x [new file with mode: 0644]
keywing/src/buffer.rs [new file with mode: 0644]
keywing/src/main.rs [new file with mode: 0644]
nrf-hal [new submodule]

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..ef75d6c
--- /dev/null
@@ -0,0 +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
diff --git a/ili9341-rs b/ili9341-rs
new file mode 160000 (submodule)
index 0000000..c732509
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit c7325094ebbc60640c4842e038c8de27beae48ad
diff --git a/keywing/.cargo/config b/keywing/.cargo/config
new file mode 100644 (file)
index 0000000..5673fa9
--- /dev/null
@@ -0,0 +1,9 @@
+[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",
+]
diff --git a/keywing/.gitignore b/keywing/.gitignore
new file mode 100644 (file)
index 0000000..53eaa21
--- /dev/null
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/keywing/Cargo.lock b/keywing/Cargo.lock
new file mode 100644 (file)
index 0000000..7b27e81
--- /dev/null
@@ -0,0 +1,371 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "aligned"
+version = "0.3.1"
+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)",
+]
+
+[[package]]
+name = "as-slice"
+version = "0.1.0"
+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)",
+]
+
+[[package]]
+name = "bare-metal"
+version = "0.2.5"
+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 = "byteorder"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "cast"
+version = "0.2.3"
+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"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "aligned 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bare-metal 0.2.5 (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"
+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)",
+ "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "cortex-m-rt-macros"
+version = "0.1.6"
+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)",
+]
+
+[[package]]
+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)",
+]
+
+[[package]]
+name = "embedded-hal"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "nb 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 = "fpa"
+version = "0.1.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)",
+]
+
+[[package]]
+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)",
+]
+
+[[package]]
+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)",
+]
+
+[[package]]
+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)",
+]
+
+[[package]]
+name = "heapless"
+version = "0.5.1"
+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)",
+ "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)",
+]
+
+[[package]]
+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)",
+]
+
+[[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"
+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)",
+]
+
+[[package]]
+name = "nrf52840-hal"
+version = "0.10.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)",
+ "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)",
+]
+
+[[package]]
+name = "nrf52840-pac"
+version = "0.9.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)",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.6"
+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)",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.2"
+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)",
+]
+
+[[package]]
+name = "r0"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "rand"
+version = "0.5.6"
+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)",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.3.1"
+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)",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "rand_core"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "rtt-target"
+version = "0.2.0"
+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)",
+ "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]]
+name = "rustc_version"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "semver"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "semver-parser"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "stable_deref_trait"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "syn"
+version = "1.0.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)",
+ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "tiny-nrf52"
+version = "0.1.0"
+dependencies = [
+ "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)",
+]
+
+[[package]]
+name = "typenum"
+version = "1.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "ufmt-write"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "vcell"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "void"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "volatile-register"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[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 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 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 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 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 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 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 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 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
new file mode 100644 (file)
index 0000000..85b93b8
--- /dev/null
@@ -0,0 +1,46 @@
+[package]
+name = "tiny-nrf52"
+version = "0.1.0"
+authors = ["James Munns <james.munns@ferrous-systems.com>"]
+edition = "2018"
+
+[dependencies]
+cortex-m-rt  = "0.6.10"
+cortex-m     = "0.6.1"
+nb           = "0.1.2"
+heapless     = "0.5.1"
+embedded-hal = "0.2"
+rtt-target   = {version = "0.2.0", features = ["cortex-m"] }
+embedded-graphics = "0.6.2"
+
+[dependencies.ili9341]
+version = "0.3.0"
+path = "../ili9341-rs"
+
+[dependencies.nrf52840-hal]
+version = "0.10.0"
+features = ["rt"]
+
+[dependencies.panic-persist]
+version = "0.2.1"
+default-features = false
+features = ["utf8"]
+
+[profile.dev]
+lto             = true
+panic           = "abort"
+debug           = true
+incremental     = false
+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" }
diff --git a/keywing/Embed.toml b/keywing/Embed.toml
new file mode 100644 (file)
index 0000000..918f48c
--- /dev/null
@@ -0,0 +1,46 @@
+[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/debug.gdb b/keywing/debug.gdb
new file mode 100644 (file)
index 0000000..3696a91
--- /dev/null
@@ -0,0 +1,6 @@
+target remote :2331
+set backtrace limit 32
+load
+monitor reset
+break main
+continue
diff --git a/keywing/memory.x b/keywing/memory.x
new file mode 100644 (file)
index 0000000..46f1278
--- /dev/null
@@ -0,0 +1,10 @@
+MEMORY
+{
+  /* NOTE K = KiBi = 1024 bytes */
+  FLASH : ORIGIN  = 0x00000000, LENGTH = 1M
+  RAM : ORIGIN    = 0x20000000, LENGTH = 255K
+  PANDUMP: ORIGIN = 0x2003FC00, LENGTH = 1K
+}
+
+_panic_dump_start = ORIGIN(PANDUMP);
+_panic_dump_end = ORIGIN(PANDUMP) + LENGTH(PANDUMP);
diff --git a/keywing/src/buffer.rs b/keywing/src/buffer.rs
new file mode 100644 (file)
index 0000000..da912ad
--- /dev/null
@@ -0,0 +1,62 @@
+use embedded_graphics::{
+    drawable::Pixel,
+    geometry::{Point, Size},
+    pixelcolor::{
+        raw::{RawData, RawU16},
+        Rgb565,
+    },
+    primitives::Rectangle,
+    style::{PrimitiveStyle, Styled},
+    DrawTarget,
+};
+
+pub struct FrameBuffer<'a> {
+    buf: &'a mut [[u16; 320]; 240],
+}
+
+impl<'a> FrameBuffer<'a> {
+    pub fn new(raw: &'a mut [[u16; 320]; 240]) -> Self {
+        Self {
+            buf: raw
+        }
+    }
+
+    pub fn inner(&self) -> &[u16] {
+        unsafe {
+            core::slice::from_raw_parts(self.buf.as_ptr().cast::<u16>(), (self.width() * self.height()) as usize)
+        }
+    }
+
+    fn width(&self) -> u32 {
+        self.buf.len() as u32
+    }
+
+    fn height(&self) -> u32 {
+        self.buf[0].len() as u32
+    }
+}
+
+impl<'a> DrawTarget<Rgb565> for FrameBuffer<'a>
+{
+    type Error = ();
+
+    fn size(&self) -> Size {
+        Size::new(self.width(), self.height())
+    }
+
+    fn draw_pixel(&mut self, pixel: Pixel<Rgb565>) -> Result<(), Self::Error> {
+        let Pixel(pos, color) = pixel;
+
+        if pos.x < 0 || pos.y < 0 || pos.x >= self.width() as i32 || pos.y >= self.height() as i32 {
+            return Ok(());
+        }
+
+        self.buf[pos.y as usize][pos.x as usize] = swap(RawU16::from(color).into_inner());
+        Ok(())
+    }
+}
+
+const fn swap(inp: u16) -> u16 {
+    (inp & 0x00FF) << 8 |
+    (inp & 0xFF00) >> 8
+}
diff --git a/keywing/src/main.rs b/keywing/src/main.rs
new file mode 100644 (file)
index 0000000..fd71350
--- /dev/null
@@ -0,0 +1,483 @@
+#![no_std]
+#![no_main]
+
+// Panic provider crate
+use panic_persist;
+use cortex_m;
+
+// Used to set the program entry point
+use cortex_m_rt::entry;
+
+// Provides definitions for our development board
+use nrf52840_hal::{
+    prelude::*,
+    target::{Peripherals, CorePeripherals},
+    Timer,
+    Rng,
+    Spim,
+    spim::{
+        Pins as SpimPins,
+        Frequency as SpimFrequency,
+        MODE_0,
+    },
+    gpio::{
+        p0::Parts as P0Parts,
+        p1::Parts as P1Parts,
+        Level,
+    },
+    Clocks,
+};
+
+use rtt_target::{
+    rprint, rprintln,
+    rtt_init_print,
+};
+
+use embedded_graphics::{
+    fonts::{Font8x16, Text},
+    pixelcolor::Rgb565,
+    prelude::*,
+    style::{TextStyle, TextStyleBuilder},
+};
+
+mod buffer;
+
+use ili9341::{Ili9341, Orientation};
+
+const TEXT_SAMPLE: &[&str] = &[
+    "for x in 0..10 {",
+    "  for y in 0..10 {",
+    "    let rand: u16 = rng.random_u16();",
+    "    buffy.iter_mut().for_each(|px| {",
+    "      *px = swap(rand)",
+    "    });",
+    "    lcd.draw_raw(",
+    "      32 * x,",
+    "      24 * y,",
+    "      (32 * (x + 1)) - 1,",
+    "      (24 * (y + 1)) - 1,",
+    "      &buffy,",
+    "    ).unwrap();",
+    "  }",
+    "}",
+];
+
+const TEXT_SAMPLE2: &[&[(i32, Rgb565, &str)]] = &[
+    // "for x in 0..10 {",
+    &[(0, Rgb565::RED, "for "), (4, Rgb565::WHITE, "x "), (6, Rgb565::RED, "in "), (9, Rgb565::MAGENTA, "0"), (10, Rgb565::RED, ".."), (12, Rgb565::MAGENTA, "10"), (14, Rgb565::WHITE, " {")],
+    // "  for y in 0..10 {",
+    &[(2, Rgb565::RED, "for "), (6, Rgb565::WHITE, "y "), (8, Rgb565::RED, "in "), (11, Rgb565::MAGENTA, "0"), (12, Rgb565::RED, ".."), (14, Rgb565::MAGENTA, "10"), (16, Rgb565::WHITE, " {")],
+    // "    let rand: u16 = rng.random_u16();",
+    &[(4, Rgb565::CYAN, "let "), (8, Rgb565::WHITE, "rand: "), (14, Rgb565::CYAN, "u16 "), (18, Rgb565::RED, "= "), (20, Rgb565::WHITE, "rng."), (24, Rgb565::CYAN, "random_u16"), (34, Rgb565::WHITE, "();")],
+    // "    buffy.iter_mut().for_each(|px| {",
+    &[(4, Rgb565::WHITE, "buffy."), (10, Rgb565::CYAN, "iter_mut"), (18, Rgb565::WHITE, "()."), (21, Rgb565::CYAN, "for_each"), (29, Rgb565::WHITE, "(|"), (31, Rgb565::YELLOW, "px"), (33, Rgb565::WHITE, "| {")],
+    // "      *px = swap(rand)",
+    &[(6, Rgb565::RED, "*"), (7, Rgb565::WHITE, "px "), (10, Rgb565::RED, "= "), (12, Rgb565::CYAN, "swap"), (16, Rgb565::WHITE, "(rand)")],
+    // "    });",
+    &[(4, Rgb565::WHITE, "});")],
+    // "    lcd.draw_raw(",
+    &[(4, Rgb565::WHITE, "lcd."), (8, Rgb565::CYAN, "draw_raw"), (16, Rgb565::WHITE, "(")],
+    // "      32 * x,",
+    &[(6, Rgb565::MAGENTA, "32 "), (9, Rgb565::RED, "* "), (11, Rgb565::WHITE, "x,")],
+    // "      24 * y,",
+    &[(6, Rgb565::MAGENTA, "24 "), (9, Rgb565::RED, "* "), (11, Rgb565::WHITE, "y,")],
+    // "      (32 * (x + 1)) - 1,",
+    &[(6, Rgb565::WHITE, "("), (7, Rgb565::MAGENTA,"32 "), (10, Rgb565::RED, "* "), (12, Rgb565::WHITE, "(x "), (15, Rgb565::RED, "+ "), (17, Rgb565::MAGENTA, "1"), (18, Rgb565::WHITE, ")) "), (21, Rgb565::RED, "- "), (23, Rgb565::MAGENTA, "1"), (24, Rgb565::WHITE, ",")],
+    // "      (24 * (y + 1)) - 1,",
+    &[(6, Rgb565::WHITE, "("), (7, Rgb565::MAGENTA,"24 "), (10, Rgb565::RED, "* "), (12, Rgb565::WHITE, "(y "), (15, Rgb565::RED, "+ "), (17, Rgb565::MAGENTA, "1"), (18, Rgb565::WHITE, ")) "), (21, Rgb565::RED, "- "), (23, Rgb565::MAGENTA, "1"), (24, Rgb565::WHITE, ",")],
+    // "      &buffy,",
+    &[(6, Rgb565::RED, "&"), (7, Rgb565::WHITE, "buffy,")],
+    // "    ).unwrap();",
+    &[(4, Rgb565::WHITE, ")."), (6, Rgb565::CYAN, "unwrap"), (12, Rgb565::WHITE, "();")],
+    // "  }",
+    &[(2, Rgb565::WHITE, "}")],
+    // "}",
+    &[(0, Rgb565::WHITE, "}")],
+];
+
+#[entry]
+fn main() -> ! {
+    match inner_main() {
+        Ok(()) => cortex_m::peripheral::SCB::sys_reset(),
+        Err(e) => panic!(e),
+    }
+}
+
+fn inner_main() -> Result<(), &'static str> {
+    let mut board = Peripherals::take().ok_or("Error getting board!")?;
+    let mut corep = CorePeripherals::take().ok_or("Error")?;
+    let mut timer = Timer::new(board.TIMER0);
+    let mut delay = Timer::new(board.TIMER1);
+    let mut rng = Rng::new(board.RNG);
+    let mut toggle = false;
+    let _clocks = Clocks::new(board.CLOCK).enable_ext_hfosc();
+
+    // use ChannelMode::NoBlockS
+    rtt_init_print!(NoBlockSkip, 4096);
+
+    if let Some(msg) = panic_persist::get_panic_message_utf8() {
+        rprintln!("{}", msg);
+    } else {
+        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
+
+    // Pull the neopixel line 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 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 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),
+        &mut delay,
+    ).unwrap();
+
+    lcd.set_orientation(Orientation::Landscape).unwrap();
+
+    let mut buffy = [0u16; 24 * 32];
+    let mut buffy2 = [[0u16; 320]; 240];
+
+    let mut fbuffy = buffer::FrameBuffer::new(&mut buffy2);
+
+    // //                                     rrrrr gggggg bbbbb
+    // buffy.iter_mut().for_each(|px| *px = 0b11111_000000_00000);
+
+    let style = TextStyleBuilder::new(Font8x16)
+        .text_color(Rgb565::WHITE)
+        .background_color(Rgb565::BLACK)
+        .build();
+
+    loop {
+
+        rprintln!("Start colors raw");
+
+        for x in 0..10 {
+            for y in 0..10 {
+                let rand: u16 = rng.random_u16();
+                buffy.iter_mut().for_each(|px| {
+                    *px = swap(rand)
+                });
+
+                lcd.draw_raw(
+                    32 * x,
+                    24 * y,
+                    (32 * (x + 1)) - 1,
+                    (24 * (y + 1)) - 1,
+                    &buffy,
+                ).unwrap();
+            }
+        }
+
+        rprintln!("Done.\n");
+
+        timer.delay_ms(1000u16);
+
+        rprintln!("Start colors raw");
+
+        for x in 0..10 {
+            for y in 0..10 {
+                let rand: u16 = 0;
+                buffy.iter_mut().for_each(|px| {
+                    *px = swap(rand)
+                });
+
+                lcd.draw_raw(
+                    32 * x,
+                    24 * y,
+                    (32 * (x + 1)) - 1,
+                    (24 * (y + 1)) - 1,
+                    &buffy,
+                ).unwrap();
+            }
+        }
+
+        rprintln!("Done.\n");
+
+
+        timer.delay_ms(1000u16);
+
+        // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_00000));
+        // rprintln!("Start black");
+        // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+        // rprintln!("Done.\n");
+
+        rprintln!("text start");
+
+        for row in 0..15 {
+            Text::new(
+                TEXT_SAMPLE[row as usize],
+                Point::new(0, row * 16)
+            ).into_styled(style)
+            .draw(&mut lcd)
+            .unwrap();
+        }
+
+        rprintln!("text done");
+
+        timer.delay_ms(3000u16);
+
+        rprintln!("Start colors raw");
+
+        for x in 0..10 {
+            for y in 0..10 {
+                let rand: u16 = 0;
+                buffy.iter_mut().for_each(|px| {
+                    *px = swap(rand)
+                });
+
+                lcd.draw_raw(
+                    32 * x,
+                    24 * y,
+                    (32 * (x + 1)) - 1,
+                    (24 * (y + 1)) - 1,
+                    &buffy,
+                ).unwrap();
+            }
+        }
+
+        rprintln!("Done.\n");
+
+
+        timer.delay_ms(1000u16);
+
+        // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_00000));
+        // rprintln!("Start black");
+        // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+        // rprintln!("Done.\n");
+
+        rprintln!("text2 start");
+
+        for (i, row) in TEXT_SAMPLE2.iter().enumerate() {
+            for (offset, color, text) in row.iter() {
+                let styled = TextStyleBuilder::new(Font8x16)
+                    .text_color(*color)
+                    .background_color(Rgb565::BLACK)
+                    .build();
+
+                Text::new(
+                    text,
+                    Point::new(*offset * 8, i as i32 * 16)
+                ).into_styled(styled)
+                .draw(&mut lcd)
+                .unwrap();
+            }
+        }
+
+        rprintln!("text2 done");
+
+        timer.delay_ms(3000u16);
+
+        rprintln!("Start colors raw");
+
+        for x in 0..10 {
+            for y in 0..10 {
+                let rand: u16 = 0;
+                buffy.iter_mut().for_each(|px| {
+                    *px = swap(rand)
+                });
+
+                lcd.draw_raw(
+                    32 * x,
+                    24 * y,
+                    (32 * (x + 1)) - 1,
+                    (24 * (y + 1)) - 1,
+                    &buffy,
+                ).unwrap();
+            }
+        }
+
+        rprintln!("Done.\n");
+
+        timer.delay_ms(1000u16);
+
+        // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_00000));
+        // rprintln!("Start black");
+        // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+        // rprintln!("Done.\n");
+
+        timer.start(1_000_000u32);
+
+        let start: u32 = timer.read();
+
+        for row in 0..15 {
+            Text::new(
+                TEXT_SAMPLE[row as usize],
+                Point::new(0, row * 16)
+            ).into_styled(style)
+            .draw(&mut fbuffy)
+            .unwrap();
+        }
+
+        let middle: u32 = timer.read();
+
+        lcd.draw_raw(0, 0, 319, 239, fbuffy.inner()).unwrap();
+
+        let end: u32 = timer.read();
+
+        rprintln!("text buffered done");
+        rprintln!("start: 0x{:08X}, middle: 0x{:08X}, end: 0x{:08X}", start, middle, end);
+        rprintln!("render: {} cycs", middle - start);
+        rprintln!("draw:   {} cycs", end - middle);
+
+
+
+
+
+        timer.delay_ms(3000u16);
+
+        rprintln!("Start colors raw");
+
+        for x in 0..10 {
+            for y in 0..10 {
+                let rand: u16 = 0;
+                buffy.iter_mut().for_each(|px| {
+                    *px = swap(rand)
+                });
+
+                lcd.draw_raw(
+                    32 * x,
+                    24 * y,
+                    (32 * (x + 1)) - 1,
+                    (24 * (y + 1)) - 1,
+                    &buffy,
+                ).unwrap();
+            }
+        }
+
+        rprintln!("Done.\n");
+
+
+        timer.delay_ms(1000u16);
+
+        rprintln!("text2 buffered middle");
+
+        for (i, row) in TEXT_SAMPLE2.iter().enumerate() {
+            for (offset, color, text) in row.iter() {
+                let styled = TextStyleBuilder::new(Font8x16)
+                    .text_color(*color)
+                    .background_color(Rgb565::BLACK)
+                    .build();
+
+                Text::new(
+                    text,
+                    Point::new(*offset * 8, i as i32 * 16)
+                ).into_styled(styled)
+                .draw(&mut fbuffy)
+                .unwrap();
+            }
+        }
+
+        rprintln!("text2 buffered middle");
+
+        lcd.draw_raw(0, 0, 319, 239, fbuffy.inner()).unwrap();
+
+        rprintln!("text2 buffered done");
+
+        timer.delay_ms(3000u16);
+
+        continue;
+
+
+        // // SHOULD BE
+        // //                                      rrrrr gggggg bbbbb
+        // buffy2.iter_mut().for_each(|px| *px = swap(0b11111_000000_00000));
+        // rprintln!("Start red");
+        // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+        // rprintln!("Done.\n");
+
+        // timer.delay_ms(250u16);
+
+        // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_111111_00000));
+        // rprintln!("Start green");
+        // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+        // rprintln!("Done.\n");
+
+        // timer.delay_ms(250u16);
+
+        // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_11111));
+        // rprintln!("Start blue");
+        // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+        // rprintln!("Done.\n");
+
+        // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_00000));
+        // rprintln!("Start black");
+        // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+        // rprintln!("Done.\n");
+
+        // 240 / 16: 15
+        // 320 /  8: 40
+
+        let text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+
+        let mut textiter = text.chars().cycle();
+
+        for row in 0..15 {
+            for col in 0..40 {
+                let mut buf = [0u8; 4];
+                let txt = textiter.next().unwrap().encode_utf8(&mut buf);
+                Text::new(
+                    txt,
+                    Point::new(col * 8, row * 16)
+                ).into_styled(style)
+                .draw(&mut lcd)
+                .unwrap();
+            }
+            timer.delay_ms(500u16);
+        }
+
+        timer.delay_ms(1000u16);
+
+
+        // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_00000));
+        // rprintln!("Start black");
+        // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+        // rprintln!("Done.\n");
+
+        rprintln!("Starting Text Fill...");
+
+        let mut text = Text::new(
+            "1234567890123456789012345678901234567890",
+            Point::new(0, 0)
+        ).into_styled(style);
+
+        for _y in 0..15 {
+            text.draw(&mut lcd).unwrap();
+            text = text.translate(Point::new(0, 16));
+        }
+
+        rprintln!("Finished Text Fill.");
+
+
+        timer.delay_ms(1000u16);
+
+
+    }
+
+    Ok(())
+}
+
+const fn swap(inp: u16) -> u16 {
+    (inp & 0x00FF) << 8 |
+    (inp & 0xFF00) >> 8
+}
diff --git a/nrf-hal b/nrf-hal
new file mode 160000 (submodule)
index 0000000..f98fe76
--- /dev/null
+++ b/nrf-hal
@@ -0,0 +1 @@
+Subproject commit f98fe76b4b0d43a8a542c0002ce6b2568d9f4070