Initial, mostly working RMP firmware
Signed-off-by: fly <merspieler@alwaysdata.net>
This commit is contained in:
parent
06ba5a9f2b
commit
1fda29dcc8
13 changed files with 1186 additions and 0 deletions
12
Pedestal/RMP/README.md
Normal file
12
Pedestal/RMP/README.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# RMP
|
||||
## USB HID
|
||||
### Output
|
||||
2 Byte output, consisting of
|
||||
* 1 Byte for the reportId (always value 1)
|
||||
TODO
|
||||
|
||||
## Firmware
|
||||
use the `--features FO` and `--features third` flags to compile for the FO and 3rd occupant RMPs
|
||||
|
||||
## Display
|
||||
TODO find a fitting display
|
11
Pedestal/RMP/firmware/.cargo/config
Normal file
11
Pedestal/RMP/firmware/.cargo/config
Normal file
|
@ -0,0 +1,11 @@
|
|||
[target.thumbv7m-none-eabi]
|
||||
runner = 'arm-none-eabi-gdb'
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
]
|
||||
|
||||
[build]
|
||||
target = "thumbv7m-none-eabi"
|
||||
|
||||
[unstable]
|
||||
build-std = ["core", "alloc"]
|
18
Pedestal/RMP/firmware/.gdbinit
Normal file
18
Pedestal/RMP/firmware/.gdbinit
Normal file
|
@ -0,0 +1,18 @@
|
|||
target remote :3333
|
||||
|
||||
monitor arm semihosting enable
|
||||
|
||||
# # send captured ITM to the file itm.fifo
|
||||
# # (the microcontroller SWO pin must be connected to the programmer SWO pin)
|
||||
# # 8000000 must match the core clock frequency
|
||||
# monitor tpiu config internal itm.fifo uart off 8000000
|
||||
|
||||
# # OR: make the microcontroller SWO pin output compatible with UART (8N1)
|
||||
# # 2000000 is the frequency of the SWO pin
|
||||
# monitor tpiu config external uart off 8000000 2000000
|
||||
|
||||
# # enable ITM port 0
|
||||
# monitor itm port 0 on
|
||||
|
||||
load
|
||||
step
|
526
Pedestal/RMP/firmware/Cargo.lock
generated
Normal file
526
Pedestal/RMP/firmware/Cargo.lock
generated
Normal file
|
@ -0,0 +1,526 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bare-metal"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
|
||||
dependencies = [
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bare-metal"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603"
|
||||
|
||||
[[package]]
|
||||
name = "bitfield"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitvec"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
|
||||
dependencies = [
|
||||
"funty",
|
||||
"radium",
|
||||
"tap",
|
||||
"wyz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bxcan"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40ac3d0c0a542d0ab5521211f873f62706a7136df415676f676d347e5a41dd80"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"embedded-hal",
|
||||
"nb 1.1.0",
|
||||
"vcell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15"
|
||||
dependencies = [
|
||||
"bytemuck_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck_derive"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4da9a32f3fed317401fa3c862968128267c3106685286e15d5aaa3d7389c2f60"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.55",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "cortex-m"
|
||||
version = "0.7.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9"
|
||||
dependencies = [
|
||||
"bare-metal 0.2.5",
|
||||
"bitfield",
|
||||
"embedded-hal",
|
||||
"volatile-register",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cortex-m-rt"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee84e813d593101b1723e13ec38b6ab6abbdbaaa4546553f5395ed274079ddb1"
|
||||
dependencies = [
|
||||
"cortex-m-rt-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cortex-m-rt-macros"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0f6f3e36f203cfedbc78b357fb28730aa2c6dc1ab060ee5c2405e843988d3c7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cortex-m-semihosting"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c23234600452033cc77e4b761e740e02d2c4168e11dbf36ab14a0f58973592b0"
|
||||
dependencies = [
|
||||
"cortex-m",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-dma"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "994f7e5b5cb23521c22304927195f236813053eb9c065dd2226a32ba64695446"
|
||||
dependencies = [
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-hal"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff"
|
||||
dependencies = [
|
||||
"nb 0.1.3",
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "firmware"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cortex-m",
|
||||
"cortex-m-rt",
|
||||
"embedded-hal",
|
||||
"fugit",
|
||||
"nb 1.1.0",
|
||||
"packed_struct",
|
||||
"panic-halt",
|
||||
"panic-semihosting",
|
||||
"ryu",
|
||||
"stm32f1xx-hal",
|
||||
"usb-device",
|
||||
"usbd-human-interface-device",
|
||||
"usbd-serial",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "frunk"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11a351b59e12f97b4176ee78497dff72e4276fb1ceb13e19056aca7fa0206287"
|
||||
dependencies = [
|
||||
"frunk_core",
|
||||
"frunk_derives",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "frunk_core"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af2469fab0bd07e64ccf0ad57a1438f63160c69b2e57f04a439653d68eb558d6"
|
||||
|
||||
[[package]]
|
||||
name = "frunk_derives"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0fa992f1656e1707946bbba340ad244f0814009ef8c0118eb7b658395f19a2e"
|
||||
dependencies = [
|
||||
"frunk_proc_macro_helpers",
|
||||
"quote",
|
||||
"syn 2.0.55",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "frunk_proc_macro_helpers"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35b54add839292b743aeda6ebedbd8b11e93404f902c56223e51b9ec18a13d2c"
|
||||
dependencies = [
|
||||
"frunk_core",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.55",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fugit"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17186ad64927d5ac8f02c1e77ccefa08ccd9eaa314d5a4772278aa204a22f7e7"
|
||||
dependencies = [
|
||||
"gcd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fugit-timer"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9607bfc4c388f9d629704f56ede4a007546cad417b3bcd6fc7c87dc7edce04a"
|
||||
dependencies = [
|
||||
"fugit",
|
||||
"nb 1.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "funty"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
|
||||
|
||||
[[package]]
|
||||
name = "gcd"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a"
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad"
|
||||
dependencies = [
|
||||
"hash32",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nb"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f"
|
||||
dependencies = [
|
||||
"nb 1.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nb"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d"
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845"
|
||||
dependencies = [
|
||||
"num_enum_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum_derive"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.55",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "option-block"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0f2c5d345596a14d7c8b032a68f437955f0059f2eb9a5972371c84f7eef3227"
|
||||
|
||||
[[package]]
|
||||
name = "packed_struct"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36b29691432cc9eff8b282278473b63df73bea49bc3ec5e67f31a3ae9c3ec190"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"packed_struct_codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "packed_struct_codegen"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cd6706dfe50d53e0f6aa09e12c034c44faacd23e966ae5a209e8bdb8f179f98"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "panic-halt"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de96540e0ebde571dc55c73d60ef407c653844e6f9a1e2fdbd40c07b9252d812"
|
||||
|
||||
[[package]]
|
||||
name = "panic-semihosting"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee8a3e1233d9073d76a870223512ce4eeea43c067a94a445c13bd6d792d7b1ab"
|
||||
dependencies = [
|
||||
"cortex-m",
|
||||
"cortex-m-semihosting",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "radium"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
dependencies = [
|
||||
"semver-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver-parser"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "stm32-usbd"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6c94998f166d66b210a164648a0b7866428d8f1e0740bf8a4c5edd89d4750c1"
|
||||
dependencies = [
|
||||
"cortex-m",
|
||||
"usb-device",
|
||||
"vcell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stm32f1"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2dc80735831c28fe85384e1e28428fb6d201f67c696e369a239ed9c5eba369d"
|
||||
dependencies = [
|
||||
"bare-metal 1.0.0",
|
||||
"cortex-m",
|
||||
"cortex-m-rt",
|
||||
"vcell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stm32f1xx-hal"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30845662b9ce46a2ec04da97666a2b32458bee5032bb0452d0caf1536a96a542"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bxcan",
|
||||
"cortex-m",
|
||||
"cortex-m-rt",
|
||||
"embedded-dma",
|
||||
"embedded-hal",
|
||||
"fugit",
|
||||
"fugit-timer",
|
||||
"nb 1.1.0",
|
||||
"stm32-usbd",
|
||||
"stm32f1",
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tap"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "usb-device"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f6cc3adc849b5292b4075fc0d5fdcf2f24866e88e336dd27a8943090a520508"
|
||||
|
||||
[[package]]
|
||||
name = "usbd-human-interface-device"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d69710303c06f23a1259d086bfb241212ae1ccfb5d582ebd596bb042d662ed73"
|
||||
dependencies = [
|
||||
"frunk",
|
||||
"fugit",
|
||||
"heapless",
|
||||
"num_enum",
|
||||
"option-block",
|
||||
"packed_struct",
|
||||
"usb-device",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "usbd-serial"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db75519b86287f12dcf0d171c7cf4ecc839149fe9f3b720ac4cfce52959e1dfe"
|
||||
dependencies = [
|
||||
"embedded-hal",
|
||||
"nb 0.1.3",
|
||||
"usb-device",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcell"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
|
||||
|
||||
[[package]]
|
||||
name = "void"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
|
||||
[[package]]
|
||||
name = "volatile-register"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc"
|
||||
dependencies = [
|
||||
"vcell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wyz"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
|
||||
dependencies = [
|
||||
"tap",
|
||||
]
|
41
Pedestal/RMP/firmware/Cargo.toml
Normal file
41
Pedestal/RMP/firmware/Cargo.toml
Normal file
|
@ -0,0 +1,41 @@
|
|||
[package]
|
||||
name = "firmware"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
embedded-hal = "0.2.7"
|
||||
nb = "1"
|
||||
cortex-m = "0.7.6"
|
||||
cortex-m-rt = "0.7.1"
|
||||
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
|
||||
panic-halt = "0.2.0"
|
||||
#stm32-usbd = "0.6.0"
|
||||
usb-device = "0.2.9"
|
||||
usbd-serial = "0.1.1"
|
||||
ryu = "1.0.16"
|
||||
panic-semihosting = "0.6.0"
|
||||
usbd-human-interface-device = "0.4.5"
|
||||
packed_struct = { version = "0.10.1", default-features = false }
|
||||
fugit = "0.3.7"
|
||||
bytemuck = { version = "1.15.0", features = ["derive"] }
|
||||
|
||||
[dependencies.stm32f1xx-hal]
|
||||
version = "0.10.0"
|
||||
features = ["rt", "stm32f103"]
|
||||
|
||||
[profile.dev]
|
||||
codegen-units = 1
|
||||
opt-level = "z"
|
||||
panic="abort"
|
||||
|
||||
[profile.dev.package."*"]
|
||||
codegen-units = 1
|
||||
opt-level = "z"
|
||||
|
||||
[profile.release]
|
||||
# or "z"
|
||||
opt-level = "z"
|
||||
panic="abort"
|
65
Pedestal/RMP/firmware/descriptor.wara
Normal file
65
Pedestal/RMP/firmware/descriptor.wara
Normal file
|
@ -0,0 +1,65 @@
|
|||
[[applicationCollection]]
|
||||
usage = ['Generic Desktop', 'Joystick']
|
||||
|
||||
[[applicationCollection.inputReport]]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection]]
|
||||
usage = ['Generic Desktop', 'Pointer']
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.physicalCollection.variableItem]]
|
||||
usage = ['Generic Desktop', 'Z']
|
||||
logicalValueRange = [0, 65535]
|
||||
|
||||
[[applicationCollection.inputReport.variableItem]]
|
||||
usageRange = ['Button', 'Button 1', 'Button 64']
|
||||
logicalValueRange = [0, 1]
|
||||
|
||||
[[applicationCollection.outputReport]]
|
||||
|
||||
[[applicationCollection.outputReport.variableItem]]
|
||||
usage = ['Haptics', 'Manual Trigger']
|
||||
logicalValueRange = [0, 65535]
|
3
Pedestal/RMP/firmware/hidtools.sh
Executable file
3
Pedestal/RMP/firmware/hidtools.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#! /usr/bin/env bash
|
||||
nix run github:feathecutie/hidtools -- -s descriptor.wara
|
||||
cat descriptor.h |grep " 0x"
|
7
Pedestal/RMP/firmware/memory.x
Normal file
7
Pedestal/RMP/firmware/memory.x
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* Linker script for the STM32F103C8T6 */
|
||||
MEMORY
|
||||
{
|
||||
/* We only use 63KiB so we have 1KiB free for calibration data */
|
||||
FLASH : ORIGIN = 0x08000000, LENGTH = 63K
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 20K
|
||||
}
|
12
Pedestal/RMP/firmware/openocd.cfg
Normal file
12
Pedestal/RMP/firmware/openocd.cfg
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Sample OpenOCD configuration for the STM32F3DISCOVERY development board
|
||||
|
||||
# Depending on the hardware revision you got you'll have to pick ONE of these
|
||||
# interfaces. At any time only one interface should be commented out.
|
||||
|
||||
# Revision C (newer revision)
|
||||
source [find interface/jlink.cfg]
|
||||
|
||||
# Revision A and B (older revisions)
|
||||
# source [find interface/stlink-v2.cfg]
|
||||
|
||||
source [find target/stm32f1x.cfg]
|
2
Pedestal/RMP/firmware/openocd.sh
Executable file
2
Pedestal/RMP/firmware/openocd.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#! /usr/bin/env bash
|
||||
openocd -f interface/jlink.cfg -f ./swd.cfg -f target/stm32f1x.cfg
|
157
Pedestal/RMP/firmware/src/device.rs
Normal file
157
Pedestal/RMP/firmware/src/device.rs
Normal file
|
@ -0,0 +1,157 @@
|
|||
use core::default::Default;
|
||||
use fugit::ExtU32;
|
||||
use packed_struct::prelude::*;
|
||||
use usb_device::bus::UsbBus;
|
||||
use usb_device::class_prelude::UsbBusAllocator;
|
||||
use usbd_human_interface_device::{
|
||||
descriptor::InterfaceProtocol,
|
||||
device::DeviceClass,
|
||||
interface::{
|
||||
InBytes64, Interface, InterfaceBuilder, InterfaceConfig, OutBytes64, ReportSingle,
|
||||
UsbAllocatable,
|
||||
},
|
||||
UsbHidError,
|
||||
};
|
||||
|
||||
// Generated using Waratah
|
||||
#[rustfmt::skip]
|
||||
pub const CUSTOM_DESCRIPTOR: &[u8] = &[
|
||||
0x05, 0x01, // UsagePage(Generic Desktop[0x0001])
|
||||
0x09, 0x04, // UsageId(Joystick[0x0004])
|
||||
0xA1, 0x01, // Collection(Application)
|
||||
0x85, 0x01, // ReportId(1)
|
||||
0x09, 0x01, // UsageId(Pointer[0x0001])
|
||||
0xA1, 0x00, // Collection(Physical)
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x09, 0x32, // UsageId(Z[0x0032])
|
||||
0x15, 0x00, // LogicalMinimum(0)
|
||||
0x26, 0xFF, 0x0F, // LogicalMaximum(4,095)
|
||||
0x95, 0x0C, // ReportCount(12)
|
||||
0x75, 0x10, // ReportSize(16)
|
||||
0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField)
|
||||
0xC0, // EndCollection()
|
||||
0x05, 0x09, // UsagePage(Button[0x0009])
|
||||
0x19, 0x01, // UsageIdMin(Button 1[0x0001])
|
||||
0x29, 0x40, // UsageIdMax(Button 64[0x0040])
|
||||
0x25, 0x01, // LogicalMaximum(1)
|
||||
0x95, 0x40, // ReportCount(64)
|
||||
0x75, 0x01, // ReportSize(1)
|
||||
0x81, 0x02, // Input(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, BitField)
|
||||
0x05, 0x0E, // UsagePage(Haptics[0x000E])
|
||||
0x09, 0x21, // UsageId(Manual Trigger[0x0021])
|
||||
0x27, 0xFF, 0xFF, 0x00, 0x00, // LogicalMaximum(65,535)
|
||||
0x95, 0x01, // ReportCount(1)
|
||||
0x75, 0x10, // ReportSize(16)
|
||||
0x91, 0x02, // Output(Data, Variable, Absolute, NoWrap, Linear, PreferredState, NoNullPosition, NonVolatile, BitField)
|
||||
0xC0, // EndCollection()
|
||||
];
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Default, PackedStruct)]
|
||||
#[packed_struct(endian = "lsb", size_bytes = "33")] // MUST be <= 64 else we get problem cause InBytes64 or OutBytes64
|
||||
pub struct CustomInputReport {
|
||||
#[packed_field]
|
||||
pub report_id: u8,
|
||||
#[packed_field]
|
||||
pub axis: [u16; 12],
|
||||
#[packed_field]
|
||||
pub transmission_buttons: u16,
|
||||
#[packed_field]
|
||||
pub numpad_buttons: u16,
|
||||
#[packed_field]
|
||||
pub select_buttons: u32,
|
||||
// #[packed_field]
|
||||
// pub buttons: u16,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Default, PackedStruct)]
|
||||
#[packed_struct(endian = "lsb", size_bytes = "3")]
|
||||
pub struct CustomOutputReport {
|
||||
#[packed_field]
|
||||
pub report_id: u8,
|
||||
#[packed_field]
|
||||
pub leds: u16,
|
||||
}
|
||||
|
||||
pub struct CustomDevice<'a, B: UsbBus> {
|
||||
interface: Interface<'a, B, InBytes64, OutBytes64, ReportSingle>,
|
||||
}
|
||||
|
||||
impl<'a, B: UsbBus> CustomDevice<'a, B> {
|
||||
pub fn write_report(&mut self, report: &CustomInputReport) -> Result<(), UsbHidError> {
|
||||
let data = report.pack().map_err(|_| UsbHidError::SerializationError)?;
|
||||
self.interface
|
||||
.write_report(&data)
|
||||
.map(|_| ())
|
||||
.map_err(UsbHidError::from)
|
||||
}
|
||||
|
||||
pub fn read_report(&mut self) -> Result<CustomOutputReport, UsbHidError> {
|
||||
let mut data = [0; 3];
|
||||
self.interface
|
||||
.read_report(&mut data[..])
|
||||
.map(|_| CustomOutputReport::unpack(&data).unwrap())
|
||||
.map_err(UsbHidError::from)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, B: UsbBus> DeviceClass<'a> for CustomDevice<'a, B> {
|
||||
type I = Interface<'a, B, InBytes64, OutBytes64, ReportSingle>;
|
||||
|
||||
fn interface(&mut self) -> &mut Self::I {
|
||||
&mut self.interface
|
||||
}
|
||||
|
||||
fn reset(&mut self) {}
|
||||
|
||||
fn tick(&mut self) -> Result<(), UsbHidError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomConfig<'a> {
|
||||
interface: InterfaceConfig<'a, InBytes64, OutBytes64, ReportSingle>,
|
||||
}
|
||||
|
||||
impl<'a> Default for CustomConfig<'a> {
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::new(
|
||||
InterfaceBuilder::new(CUSTOM_DESCRIPTOR)
|
||||
.unwrap()
|
||||
.boot_device(InterfaceProtocol::None)
|
||||
.description(" CustomDevice")
|
||||
.in_endpoint(10.millis())
|
||||
.unwrap()
|
||||
.with_out_endpoint(10.millis())
|
||||
.unwrap()
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> CustomConfig<'a> {
|
||||
#[must_use]
|
||||
pub fn new(interface: InterfaceConfig<'a, InBytes64, OutBytes64, ReportSingle>) -> Self {
|
||||
Self { interface }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, B: UsbBus + 'a> UsbAllocatable<'a, B> for CustomConfig<'a> {
|
||||
type Allocated = CustomDevice<'a, B>;
|
||||
|
||||
fn allocate(self, usb_alloc: &'a UsbBusAllocator<B>) -> Self::Allocated {
|
||||
Self::Allocated {
|
||||
interface: Interface::new(usb_alloc, self.interface),
|
||||
}
|
||||
}
|
||||
}
|
331
Pedestal/RMP/firmware/src/main.rs
Normal file
331
Pedestal/RMP/firmware/src/main.rs
Normal file
|
@ -0,0 +1,331 @@
|
|||
#![deny(unsafe_code)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
// Silence certain clippy warnings
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(clippy::needless_late_init)]
|
||||
#![allow(clippy::needless_return)]
|
||||
|
||||
mod device;
|
||||
|
||||
use panic_halt as _;
|
||||
|
||||
use nb::block;
|
||||
|
||||
use cortex_m::asm::delay;
|
||||
use cortex_m_rt::entry;
|
||||
use stm32f1xx_hal::{
|
||||
adc,
|
||||
gpio::{Pin, Input, Analog, PullDown, Output, PushPull},
|
||||
pac,
|
||||
prelude::*,
|
||||
timer::{Timer},
|
||||
usb::{Peripheral, UsbBus},
|
||||
};
|
||||
|
||||
// TODO addressable RGB LEDs
|
||||
|
||||
use usb_device::prelude::*;
|
||||
use usbd_human_interface_device::prelude::*;
|
||||
|
||||
use crate::device::{CustomConfig, CustomInputReport};
|
||||
|
||||
struct MyPins {
|
||||
// Analog Inputs
|
||||
pa0: Pin<'A', 0, Analog>,
|
||||
pa1: Pin<'A', 1, Analog>,
|
||||
pa2: Pin<'A', 2, Analog>,
|
||||
pa3: Pin<'A', 3, Analog>,
|
||||
pa4: Pin<'A', 4, Analog>,
|
||||
pa5: Pin<'A', 5, Analog>,
|
||||
pa6: Pin<'A', 6, Analog>,
|
||||
pb0: Pin<'B', 0, Analog>,
|
||||
pb1: Pin<'B', 1, Analog>,
|
||||
pc3: Pin<'C', 3, Analog>,
|
||||
pc4: Pin<'C', 4, Analog>,
|
||||
pc5: Pin<'C', 5, Analog>,
|
||||
|
||||
// Inputs
|
||||
pa8: Pin<'A', 8, Input<PullDown>>,
|
||||
pa9: Pin<'A', 9, Input<PullDown>>,
|
||||
pa10: Pin<'A', 10, Input<PullDown>>,
|
||||
pb2: Pin<'B', 2, Input<PullDown>>,
|
||||
pb9: Pin<'B', 9, Input<PullDown>>,
|
||||
pb11: Pin<'B', 11, Input<PullDown>>,
|
||||
pb12: Pin<'B', 12, Input<PullDown>>,
|
||||
pb13: Pin<'B', 13, Input<PullDown>>,
|
||||
pb14: Pin<'B', 14, Input<PullDown>>,
|
||||
pb15: Pin<'B', 15, Input<PullDown>>,
|
||||
pc0: Pin<'C', 0, Input<PullDown>>,
|
||||
pc6: Pin<'C', 6, Input<PullDown>>,
|
||||
pc7: Pin<'C', 7, Input<PullDown>>,
|
||||
pc8: Pin<'C', 8, Input<PullDown>>,
|
||||
pc13: Pin<'C', 13, Input<PullDown>>,
|
||||
pc15: Pin<'C', 15, Input<PullDown>>,
|
||||
|
||||
// Outputs
|
||||
pa15: Pin<'A', 15, Output<PushPull>>,
|
||||
pb8: Pin<'B', 8, Output<PushPull>>,
|
||||
pb10: Pin<'B', 10, Output<PushPull>>,
|
||||
pc9: Pin<'C', 9, Output<PushPull>>,
|
||||
pc10: Pin<'C', 10, Output<PushPull>>,
|
||||
pc11: Pin<'C', 11, Output<PushPull>>,
|
||||
pc12: Pin<'C', 12, Output<PushPull>>,
|
||||
pc14: Pin<'C', 14, Output<PushPull>>,
|
||||
pd2: Pin<'D', 2, Output<PushPull>>,
|
||||
}
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
// ====================== general setup =================
|
||||
// Acquire peripherals
|
||||
let cp = cortex_m::Peripherals::take().unwrap();
|
||||
let p = pac::Peripherals::take().unwrap();
|
||||
let mut flash = p.FLASH.constrain();
|
||||
let rcc = p.RCC.constrain();
|
||||
|
||||
// Setup GPIOA
|
||||
let mut gpioa = p.GPIOA.split();
|
||||
let mut gpiob = p.GPIOB.split();
|
||||
let mut gpioc = p.GPIOC.split();
|
||||
let mut gpiod = p.GPIOD.split();
|
||||
|
||||
// configure clock
|
||||
let clocks = rcc
|
||||
.cfgr
|
||||
.use_hse(16.MHz())
|
||||
.sysclk(48.MHz())
|
||||
.pclk1(24.MHz())
|
||||
.freeze(&mut flash.acr);
|
||||
|
||||
let mut afio = p.AFIO.constrain();
|
||||
let (pa15, _pb3, _pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4); // To allow us to use pa15 and pb4
|
||||
|
||||
// ====================== USB setup =================
|
||||
assert!(clocks.usbclk_valid());
|
||||
let mut usb_dp = gpioa.pa12.into_push_pull_output(&mut gpioa.crh);
|
||||
usb_dp.set_low();
|
||||
delay(clocks.sysclk().raw() / 100);
|
||||
|
||||
let usb = Peripheral {
|
||||
usb: p.USB,
|
||||
pin_dm: gpioa.pa11,
|
||||
pin_dp: usb_dp.into_floating_input(&mut gpioa.crh),
|
||||
};
|
||||
let usb_bus = UsbBus::new(usb);
|
||||
|
||||
let mut consumer = UsbHidClassBuilder::new()
|
||||
.add_device(CustomConfig::default())
|
||||
.build(&usb_bus);
|
||||
|
||||
#[cfg(feature = "FO")]
|
||||
let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x16c0, 0x27d2))
|
||||
.manufacturer("FLC Meow")
|
||||
.product("RMP First Officer")
|
||||
.serial_number("01189998819991197254")
|
||||
.build();
|
||||
|
||||
#[cfg(feature = "third")]
|
||||
let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x16c0, 0x27d3))
|
||||
.manufacturer("FLC Meow")
|
||||
.product("RMP 3rd Occupant")
|
||||
.serial_number("01189998819991197255")
|
||||
.build();
|
||||
|
||||
#[cfg(not(any(feature = "FO", feature = "third")))]
|
||||
let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x16c0, 0x27d1))
|
||||
.manufacturer("FLC Meow")
|
||||
.product("RMP Captain")
|
||||
.serial_number("01189998819991197256")
|
||||
.build();
|
||||
|
||||
// ====================== ADC setup =================
|
||||
let mut adc1 = adc::Adc::adc1(p.ADC1, clocks);
|
||||
|
||||
// ====================== Pin setup =================
|
||||
let mut io_pins = MyPins {
|
||||
// Analog Inputs
|
||||
pa0: gpioa.pa0.into_analog(&mut gpioa.crl),
|
||||
pa1: gpioa.pa1.into_analog(&mut gpioa.crl),
|
||||
pa2: gpioa.pa2.into_analog(&mut gpioa.crl),
|
||||
pa3: gpioa.pa3.into_analog(&mut gpioa.crl),
|
||||
pa4: gpioa.pa4.into_analog(&mut gpioa.crl),
|
||||
pa5: gpioa.pa5.into_analog(&mut gpioa.crl),
|
||||
pa6: gpioa.pa6.into_analog(&mut gpioa.crl),
|
||||
pb0: gpiob.pb0.into_analog(&mut gpiob.crl),
|
||||
pb1: gpiob.pb1.into_analog(&mut gpiob.crl),
|
||||
pc3: gpioc.pc3.into_analog(&mut gpioc.crl),
|
||||
pc4: gpioc.pc4.into_analog(&mut gpioc.crl),
|
||||
pc5: gpioc.pc5.into_analog(&mut gpioc.crl),
|
||||
|
||||
// Inputs
|
||||
pa8: gpioa.pa8.into_pull_down_input(&mut gpioa.crh),
|
||||
pa9: gpioa.pa9.into_pull_down_input(&mut gpioa.crh),
|
||||
pa10: gpioa.pa10.into_pull_down_input(&mut gpioa.crh),
|
||||
pb2: gpiob.pb2.into_pull_down_input(&mut gpiob.crl),
|
||||
pb9: gpiob.pb9.into_pull_down_input(&mut gpiob.crh),
|
||||
pb11: gpiob.pb11.into_pull_down_input(&mut gpiob.crh),
|
||||
pb12: gpiob.pb12.into_pull_down_input(&mut gpiob.crh),
|
||||
pb13: gpiob.pb13.into_pull_down_input(&mut gpiob.crh),
|
||||
pb14: gpiob.pb14.into_pull_down_input(&mut gpiob.crh),
|
||||
pb15: gpiob.pb15.into_pull_down_input(&mut gpiob.crh),
|
||||
pc0: gpioc.pc0.into_pull_down_input(&mut gpioc.crl),
|
||||
pc6: gpioc.pc6.into_pull_down_input(&mut gpioc.crl),
|
||||
pc7: gpioc.pc7.into_pull_down_input(&mut gpioc.crl),
|
||||
pc8: gpioc.pc8.into_pull_down_input(&mut gpioc.crh),
|
||||
pc13: gpioc.pc13.into_pull_down_input(&mut gpioc.crh),
|
||||
pc15: gpioc.pc15.into_pull_down_input(&mut gpioc.crh),
|
||||
|
||||
// Outputs
|
||||
pa15: pa15.into_push_pull_output(&mut gpioa.crh),
|
||||
pb8: gpiob.pb8.into_push_pull_output(&mut gpiob.crh),
|
||||
pb10: gpiob.pb10.into_push_pull_output(&mut gpiob.crh),
|
||||
pc9: gpioc.pc9.into_push_pull_output(&mut gpioc.crh),
|
||||
pc10: gpioc.pc10.into_push_pull_output(&mut gpioc.crh),
|
||||
pc11: gpioc.pc11.into_push_pull_output(&mut gpioc.crh),
|
||||
pc12: gpioc.pc12.into_push_pull_output(&mut gpioc.crh),
|
||||
pc14: gpioc.pc14.into_push_pull_output(&mut gpioc.crh),
|
||||
pd2: gpiod.pd2.into_push_pull_output(&mut gpiod.crl),
|
||||
};
|
||||
|
||||
// ====================== Timer setup ===============
|
||||
let mut timer = Timer::syst(cp.SYST, &clocks).counter_hz();
|
||||
timer.start(1.kHz()).unwrap();
|
||||
|
||||
// ====================== Setup other vars ==========
|
||||
let mut col_select: u8 = 0;
|
||||
let mut transmission_buttons: u16 = 0; // stores the values of the keyboard matrix we can not read out right now
|
||||
let mut numpad_buttons: u16 = 0; // stores the values of the keyboard matrix we can not read out right now
|
||||
let mut select_buttons: u32 = 0; // stores the values of the keyboard matrix we can not read out right now
|
||||
|
||||
// ====================== Main loop =================
|
||||
loop {
|
||||
block!(timer.wait()).unwrap();
|
||||
// Generate report
|
||||
// Read axis
|
||||
let mut values: [u16; 12] = [0; 12];
|
||||
values[0] = adc1.read(&mut io_pins.pb1).unwrap();
|
||||
values[1] = adc1.read(&mut io_pins.pb0).unwrap();
|
||||
values[2] = adc1.read(&mut io_pins.pc5).unwrap();
|
||||
values[3] = adc1.read(&mut io_pins.pc4).unwrap();
|
||||
values[4] = adc1.read(&mut io_pins.pa6).unwrap();
|
||||
values[5] = adc1.read(&mut io_pins.pa5).unwrap();
|
||||
values[6] = adc1.read(&mut io_pins.pa4).unwrap();
|
||||
values[7] = adc1.read(&mut io_pins.pa3).unwrap();
|
||||
values[8] = adc1.read(&mut io_pins.pa2).unwrap();
|
||||
values[9] = adc1.read(&mut io_pins.pa1).unwrap();
|
||||
values[10] = adc1.read(&mut io_pins.pa0).unwrap();
|
||||
values[11] = adc1.read(&mut io_pins.pc3).unwrap();
|
||||
|
||||
// Buttons
|
||||
let mut buttons: u16 = 0;
|
||||
if io_pins.pb2.is_low() { buttons += 0x1; }
|
||||
if io_pins.pb13.is_low() { buttons += 0x2; }
|
||||
|
||||
// Transmission Keyboard matrix
|
||||
let mut transmission_buttons_read: u16 = 0;
|
||||
|
||||
if io_pins.pc0.is_high() { transmission_buttons_read += 0x1; }
|
||||
if io_pins.pc15.is_high() { transmission_buttons_read += 0x2; }
|
||||
if io_pins.pc13.is_high() { transmission_buttons_read += 0x4; }
|
||||
if io_pins.pb9.is_high() { transmission_buttons_read += 0x8; }
|
||||
|
||||
transmission_buttons = transmission_buttons & (0xFFFF - (0xF << (col_select * 4)));
|
||||
transmission_buttons += transmission_buttons_read << (col_select * 4);
|
||||
|
||||
// Numpad Keyboard matrix
|
||||
let mut numpad_buttons_read: u16 = 0;
|
||||
|
||||
if io_pins.pa10.is_high() { numpad_buttons_read += 0x1; }
|
||||
if io_pins.pa9.is_high() { numpad_buttons_read += 0x2; }
|
||||
if io_pins.pa8.is_high() { numpad_buttons_read += 0x4; }
|
||||
if io_pins.pc8.is_high() { numpad_buttons_read += 0x8; }
|
||||
|
||||
numpad_buttons = numpad_buttons & (0xFFFF - (0xF << (col_select * 4)));
|
||||
numpad_buttons += numpad_buttons_read << (col_select * 4);
|
||||
|
||||
// Select Keyboard matrix
|
||||
let mut select_buttons_read: u32 = 0;
|
||||
|
||||
if io_pins.pc7.is_high() { select_buttons_read += 0x1; }
|
||||
if io_pins.pc6.is_high() { select_buttons_read += 0x2; }
|
||||
if io_pins.pb15.is_high() { select_buttons_read += 0x4; }
|
||||
if io_pins.pb14.is_high() { select_buttons_read += 0x8; }
|
||||
if io_pins.pb12.is_high() { select_buttons_read += 0x10; }
|
||||
if io_pins.pb11.is_high() { select_buttons_read += 0x20; }
|
||||
|
||||
select_buttons = select_buttons & (0xFFFF - (0x3F << (col_select * 4)));
|
||||
select_buttons += select_buttons_read << (col_select * 4);
|
||||
|
||||
// Pull the next columns high for next time coming through in the main loop ~1ms
|
||||
if col_select == 0 {
|
||||
io_pins.pc14.set_high();
|
||||
io_pins.pb10.set_low();
|
||||
|
||||
io_pins.pc9.set_high();
|
||||
io_pins.pc12.set_low();
|
||||
|
||||
io_pins.pa15.set_high();
|
||||
io_pins.pc10.set_low();
|
||||
}
|
||||
else if col_select == 1 {
|
||||
io_pins.pb8.set_high();
|
||||
io_pins.pc14.set_low();
|
||||
|
||||
io_pins.pd2.set_high();
|
||||
io_pins.pc9.set_low();
|
||||
|
||||
io_pins.pc11.set_high();
|
||||
io_pins.pa15.set_low();
|
||||
}
|
||||
else if col_select == 2 {
|
||||
io_pins.pb10.set_high();
|
||||
io_pins.pb8.set_low();
|
||||
|
||||
io_pins.pc12.set_high();
|
||||
io_pins.pd2.set_low();
|
||||
|
||||
io_pins.pc10.set_high();
|
||||
io_pins.pc11.set_low();
|
||||
}
|
||||
|
||||
col_select += 1;
|
||||
if col_select >= 3 {
|
||||
col_select = 0
|
||||
}
|
||||
|
||||
let report = CustomInputReport {
|
||||
report_id: 1,
|
||||
axis: values,
|
||||
transmission_buttons,
|
||||
numpad_buttons,
|
||||
select_buttons,
|
||||
// buttons,
|
||||
};
|
||||
match consumer.device().write_report(&report) {
|
||||
Err(UsbHidError::WouldBlock) => {}
|
||||
Err(UsbHidError::UsbError(usb_device::UsbError::BufferOverflow)) => {
|
||||
core::panic!("Failed to write consumer report, report is too big")
|
||||
}
|
||||
Ok(_) => {
|
||||
}
|
||||
Err(e) => {
|
||||
core::panic!("Failed to write consumer report: {:?}", e)
|
||||
}
|
||||
}
|
||||
|
||||
if usb_dev.poll(&mut [&mut consumer]) {
|
||||
match consumer.device().read_report() {
|
||||
Err(UsbHidError::WouldBlock) => {}
|
||||
Ok(output) => {
|
||||
// TODO addressable RGB LEDs
|
||||
}
|
||||
Err(e) => {
|
||||
core::panic!("Failed to write consumer report: {:?}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
1
Pedestal/RMP/firmware/swd.cfg
Normal file
1
Pedestal/RMP/firmware/swd.cfg
Normal file
|
@ -0,0 +1 @@
|
|||
transport select swd
|
Loading…
Add table
Reference in a new issue