├── .cargo └── config ├── .gitignore ├── .gitmodules ├── .travis.yml ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── notes ├── 2019-03-17.md ├── 2019-03-31.md ├── alarm-clock.md └── misc.md ├── nrf52-hal-backports ├── Cargo.toml └── src │ ├── clocks.rs │ ├── delay.rs │ ├── lib.rs │ └── rtc.rs ├── pocs ├── rtc-poc │ ├── Cargo.lock │ ├── Cargo.toml │ ├── debug.gdb │ └── src │ │ └── main.rs └── sparkfun-7seg │ ├── Cargo.lock │ ├── Cargo.toml │ ├── debug.gdb │ └── src │ └── main.rs ├── protocol ├── Cargo.toml └── src │ └── lib.rs ├── sensor-node ├── Cargo.lock ├── Cargo.toml ├── debug.gdb └── src │ └── main.rs ├── spark-ser7seg ├── Cargo.toml └── src │ └── lib.rs ├── uarte-logger ├── Cargo.lock ├── Cargo.toml └── src │ └── lib.rs ├── uhr ├── Cargo.toml ├── README.md └── src │ ├── lib.rs │ ├── uhr.rs │ └── wecker.rs └── utils ├── Cargo.toml └── src └── lib.rs /.cargo/config: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "thumbv7em-none-eabihf" 3 | 4 | [target.thumbv7em-none-eabihf] 5 | runner = "arm-none-eabi-gdb -tui -q -x debug.gdb" 6 | rustflags = [ 7 | "-C", "link-arg=-Tlink.x", 8 | ] 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | scratch/ 2 | target/ 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vendor/cobs.rs"] 2 | path = vendor/cobs.rs 3 | url = https://github.com/ferrous-systems/cobs.rs.git 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | 3 | rust: 4 | - stable 5 | - beta 6 | - nightly 7 | 8 | install: 9 | - rustup target add thumbv7em-none-eabihf 10 | 11 | script: 12 | - cargo build --all 13 | - cargo test --manifest-path=./uhr/Cargo.toml --target x86_64-unknown-linux-gnu 14 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "aligned" 5 | version = "0.2.0" 6 | source = "registry+https://github.com/rust-lang/crates.io-index" 7 | 8 | [[package]] 9 | name = "aligned" 10 | version = "0.3.1" 11 | source = "registry+https://github.com/rust-lang/crates.io-index" 12 | dependencies = [ 13 | "as-slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 14 | ] 15 | 16 | [[package]] 17 | name = "as-slice" 18 | version = "0.1.0" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | dependencies = [ 21 | "generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", 22 | "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 23 | ] 24 | 25 | [[package]] 26 | name = "bare-metal" 27 | version = "0.2.4" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | dependencies = [ 30 | "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 31 | ] 32 | 33 | [[package]] 34 | name = "bitflags" 35 | version = "1.0.4" 36 | source = "registry+https://github.com/rust-lang/crates.io-index" 37 | 38 | [[package]] 39 | name = "byteorder" 40 | version = "1.3.1" 41 | source = "registry+https://github.com/rust-lang/crates.io-index" 42 | 43 | [[package]] 44 | name = "cast" 45 | version = "0.2.2" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | 48 | [[package]] 49 | name = "cortex-m" 50 | version = "0.5.10" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | dependencies = [ 53 | "aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 54 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 55 | "cortex-m 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 56 | "volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 57 | ] 58 | 59 | [[package]] 60 | name = "cortex-m" 61 | version = "0.6.0" 62 | source = "registry+https://github.com/rust-lang/crates.io-index" 63 | dependencies = [ 64 | "aligned 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 65 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 66 | "volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 67 | ] 68 | 69 | [[package]] 70 | name = "cortex-m-rt" 71 | version = "0.6.8" 72 | source = "registry+https://github.com/rust-lang/crates.io-index" 73 | dependencies = [ 74 | "cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 75 | "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 76 | ] 77 | 78 | [[package]] 79 | name = "cortex-m-rt-macros" 80 | version = "0.1.5" 81 | source = "registry+https://github.com/rust-lang/crates.io-index" 82 | dependencies = [ 83 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 84 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 85 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 86 | "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", 87 | ] 88 | 89 | [[package]] 90 | name = "cortex-m-rtfm" 91 | version = "0.4.3" 92 | source = "registry+https://github.com/rust-lang/crates.io-index" 93 | dependencies = [ 94 | "cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", 95 | "cortex-m-rt 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", 96 | "cortex-m-rtfm-macros 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 97 | "heapless 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 98 | "owned-singleton 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 99 | ] 100 | 101 | [[package]] 102 | name = "cortex-m-rtfm-macros" 103 | version = "0.4.3" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | dependencies = [ 106 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 107 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 108 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 109 | "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", 110 | ] 111 | 112 | [[package]] 113 | name = "cortex-m-semihosting" 114 | version = "0.3.2" 115 | source = "registry+https://github.com/rust-lang/crates.io-index" 116 | dependencies = [ 117 | "cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", 118 | ] 119 | 120 | [[package]] 121 | name = "dw1000" 122 | version = "0.1.0" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | dependencies = [ 125 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 126 | "ieee802154 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 127 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 128 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 129 | "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 130 | "ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 131 | ] 132 | 133 | [[package]] 134 | name = "dw1000" 135 | version = "0.2.0" 136 | source = "registry+https://github.com/rust-lang/crates.io-index" 137 | dependencies = [ 138 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 139 | "ieee802154 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 140 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 141 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 142 | "ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 143 | ] 144 | 145 | [[package]] 146 | name = "dwm1001" 147 | version = "0.1.1" 148 | source = "registry+https://github.com/rust-lang/crates.io-index" 149 | dependencies = [ 150 | "cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", 151 | "cortex-m-rt 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", 152 | "cortex-m-semihosting 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 153 | "dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 154 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 155 | "nrf52832-hal 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 156 | ] 157 | 158 | [[package]] 159 | name = "dwm1001" 160 | version = "0.2.0" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | dependencies = [ 163 | "cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", 164 | "cortex-m-rt 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", 165 | "cortex-m-semihosting 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 166 | "dw1000 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 167 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 168 | "embedded-timeout-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 169 | "nrf52832-hal 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", 170 | ] 171 | 172 | [[package]] 173 | name = "embedded-hal" 174 | version = "0.2.2" 175 | source = "registry+https://github.com/rust-lang/crates.io-index" 176 | dependencies = [ 177 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 178 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 179 | ] 180 | 181 | [[package]] 182 | name = "embedded-timeout-macros" 183 | version = "0.1.0" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | dependencies = [ 186 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 187 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 188 | ] 189 | 190 | [[package]] 191 | name = "encode_unicode" 192 | version = "0.3.5" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | 195 | [[package]] 196 | name = "fpa" 197 | version = "0.1.0" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | dependencies = [ 200 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 201 | "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 202 | ] 203 | 204 | [[package]] 205 | name = "generic-array" 206 | version = "0.11.1" 207 | source = "registry+https://github.com/rust-lang/crates.io-index" 208 | dependencies = [ 209 | "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 210 | ] 211 | 212 | [[package]] 213 | name = "generic-array" 214 | version = "0.12.0" 215 | source = "registry+https://github.com/rust-lang/crates.io-index" 216 | dependencies = [ 217 | "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 218 | ] 219 | 220 | [[package]] 221 | name = "gregor" 222 | version = "0.3.2" 223 | source = "registry+https://github.com/rust-lang/crates.io-index" 224 | 225 | [[package]] 226 | name = "hash32" 227 | version = "0.1.0" 228 | source = "registry+https://github.com/rust-lang/crates.io-index" 229 | dependencies = [ 230 | "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 231 | ] 232 | 233 | [[package]] 234 | name = "hash32-derive" 235 | version = "0.1.0" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | dependencies = [ 238 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 239 | "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 240 | "syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)", 241 | ] 242 | 243 | [[package]] 244 | name = "heapless" 245 | version = "0.4.3" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | dependencies = [ 248 | "as-slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 249 | "generic-array 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", 250 | "hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 251 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 252 | ] 253 | 254 | [[package]] 255 | name = "ieee802154" 256 | version = "0.1.1" 257 | source = "registry+https://github.com/rust-lang/crates.io-index" 258 | dependencies = [ 259 | "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 260 | "hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 261 | "hash32-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 262 | ] 263 | 264 | [[package]] 265 | name = "ieee802154" 266 | version = "0.3.0" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | dependencies = [ 269 | "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 270 | "hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 271 | "hash32-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 272 | ] 273 | 274 | [[package]] 275 | name = "nb" 276 | version = "0.1.2" 277 | source = "registry+https://github.com/rust-lang/crates.io-index" 278 | 279 | [[package]] 280 | name = "nrf52-hal-backports" 281 | version = "0.1.0" 282 | dependencies = [ 283 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 284 | "cortex-m 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 285 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 286 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 287 | ] 288 | 289 | [[package]] 290 | name = "nrf52-hal-common" 291 | version = "0.7.0" 292 | source = "registry+https://github.com/rust-lang/crates.io-index" 293 | dependencies = [ 294 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 295 | "cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", 296 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 297 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 298 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 299 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 300 | ] 301 | 302 | [[package]] 303 | name = "nrf52-hal-common" 304 | version = "0.8.1" 305 | source = "registry+https://github.com/rust-lang/crates.io-index" 306 | dependencies = [ 307 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 308 | "cortex-m 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 309 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 310 | "fpa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 311 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 312 | "nrf52832-pac 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 313 | "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 314 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 315 | ] 316 | 317 | [[package]] 318 | name = "nrf52832-hal" 319 | version = "0.7.0" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | dependencies = [ 322 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 323 | "cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", 324 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 325 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 326 | "nrf52-hal-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 327 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 328 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 329 | ] 330 | 331 | [[package]] 332 | name = "nrf52832-hal" 333 | version = "0.8.1" 334 | source = "registry+https://github.com/rust-lang/crates.io-index" 335 | dependencies = [ 336 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 337 | "cortex-m 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 338 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 339 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 340 | "nrf52-hal-common 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", 341 | "nrf52832-pac 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 342 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 343 | ] 344 | 345 | [[package]] 346 | name = "nrf52832-pac" 347 | version = "0.6.0" 348 | source = "registry+https://github.com/rust-lang/crates.io-index" 349 | dependencies = [ 350 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 351 | "cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", 352 | "cortex-m-rt 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", 353 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 354 | ] 355 | 356 | [[package]] 357 | name = "nrf52832-pac" 358 | version = "0.8.0" 359 | source = "registry+https://github.com/rust-lang/crates.io-index" 360 | dependencies = [ 361 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 362 | "cortex-m 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 363 | "cortex-m-rt 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", 364 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 365 | ] 366 | 367 | [[package]] 368 | name = "owned-singleton" 369 | version = "0.1.0" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | dependencies = [ 372 | "owned-singleton-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 373 | "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 374 | ] 375 | 376 | [[package]] 377 | name = "owned-singleton-macros" 378 | version = "0.1.0" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | dependencies = [ 381 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 382 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 383 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 384 | "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", 385 | ] 386 | 387 | [[package]] 388 | name = "panic-ramdump" 389 | version = "0.1.1" 390 | source = "registry+https://github.com/rust-lang/crates.io-index" 391 | dependencies = [ 392 | "cortex-m 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 393 | ] 394 | 395 | [[package]] 396 | name = "postcard" 397 | version = "0.3.2" 398 | source = "registry+https://github.com/rust-lang/crates.io-index" 399 | dependencies = [ 400 | "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 401 | "heapless 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 402 | "postcard-cobs 0.1.5-pre (registry+https://github.com/rust-lang/crates.io-index)", 403 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 404 | ] 405 | 406 | [[package]] 407 | name = "postcard-cobs" 408 | version = "0.1.5-pre" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | 411 | [[package]] 412 | name = "proc-macro2" 413 | version = "0.3.8" 414 | source = "registry+https://github.com/rust-lang/crates.io-index" 415 | dependencies = [ 416 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 417 | ] 418 | 419 | [[package]] 420 | name = "proc-macro2" 421 | version = "0.4.27" 422 | source = "registry+https://github.com/rust-lang/crates.io-index" 423 | dependencies = [ 424 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 425 | ] 426 | 427 | [[package]] 428 | name = "protocol" 429 | version = "0.1.0" 430 | dependencies = [ 431 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 432 | ] 433 | 434 | [[package]] 435 | name = "quote" 436 | version = "0.5.2" 437 | source = "registry+https://github.com/rust-lang/crates.io-index" 438 | dependencies = [ 439 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 440 | ] 441 | 442 | [[package]] 443 | name = "quote" 444 | version = "0.6.11" 445 | source = "registry+https://github.com/rust-lang/crates.io-index" 446 | dependencies = [ 447 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 448 | ] 449 | 450 | [[package]] 451 | name = "r0" 452 | version = "0.2.2" 453 | source = "registry+https://github.com/rust-lang/crates.io-index" 454 | 455 | [[package]] 456 | name = "rand" 457 | version = "0.5.6" 458 | source = "registry+https://github.com/rust-lang/crates.io-index" 459 | dependencies = [ 460 | "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 461 | ] 462 | 463 | [[package]] 464 | name = "rand_core" 465 | version = "0.3.1" 466 | source = "registry+https://github.com/rust-lang/crates.io-index" 467 | dependencies = [ 468 | "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 469 | ] 470 | 471 | [[package]] 472 | name = "rand_core" 473 | version = "0.4.0" 474 | source = "registry+https://github.com/rust-lang/crates.io-index" 475 | 476 | [[package]] 477 | name = "rtc-poc" 478 | version = "0.1.0" 479 | dependencies = [ 480 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 481 | "cortex-m 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 482 | "cortex-m-rtfm 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 483 | "dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 484 | "dwm1001 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 485 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 486 | "heapless 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 487 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 488 | "nrf52-hal-backports 0.1.0", 489 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 490 | "panic-ramdump 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 491 | "protocol 0.1.0", 492 | "ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 493 | "uarte-logger 0.1.0", 494 | "uhr 0.2.0", 495 | "utils 0.1.0", 496 | ] 497 | 498 | [[package]] 499 | name = "rustc_version" 500 | version = "0.2.3" 501 | source = "registry+https://github.com/rust-lang/crates.io-index" 502 | dependencies = [ 503 | "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 504 | ] 505 | 506 | [[package]] 507 | name = "semver" 508 | version = "0.9.0" 509 | source = "registry+https://github.com/rust-lang/crates.io-index" 510 | dependencies = [ 511 | "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 512 | ] 513 | 514 | [[package]] 515 | name = "semver-parser" 516 | version = "0.7.0" 517 | source = "registry+https://github.com/rust-lang/crates.io-index" 518 | 519 | [[package]] 520 | name = "sensor-node" 521 | version = "0.1.0" 522 | dependencies = [ 523 | "cortex-m-rtfm 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 524 | "dwm1001 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 525 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 526 | "embedded-timeout-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 527 | "heapless 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 528 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 529 | "panic-ramdump 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 530 | "postcard 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 531 | "protocol 0.1.0", 532 | "uarte-logger 0.1.0", 533 | "utils 0.1.0", 534 | ] 535 | 536 | [[package]] 537 | name = "serde" 538 | version = "1.0.85" 539 | source = "registry+https://github.com/rust-lang/crates.io-index" 540 | dependencies = [ 541 | "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 542 | ] 543 | 544 | [[package]] 545 | name = "serde_derive" 546 | version = "1.0.85" 547 | source = "registry+https://github.com/rust-lang/crates.io-index" 548 | dependencies = [ 549 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 550 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 551 | "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", 552 | ] 553 | 554 | [[package]] 555 | name = "spark-ser7seg" 556 | version = "0.1.0" 557 | dependencies = [ 558 | "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", 559 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 560 | ] 561 | 562 | [[package]] 563 | name = "sparkfun-7seg" 564 | version = "0.1.0" 565 | dependencies = [ 566 | "cortex-m-rtfm 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 567 | "dwm1001 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 568 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 569 | "embedded-timeout-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 570 | "heapless 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 571 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 572 | "panic-ramdump 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 573 | "postcard 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 574 | "protocol 0.1.0", 575 | "spark-ser7seg 0.1.0", 576 | "uarte-logger 0.1.0", 577 | "utils 0.1.0", 578 | ] 579 | 580 | [[package]] 581 | name = "ssmarshal" 582 | version = "1.0.0" 583 | source = "registry+https://github.com/rust-lang/crates.io-index" 584 | dependencies = [ 585 | "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 586 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 587 | ] 588 | 589 | [[package]] 590 | name = "stable_deref_trait" 591 | version = "1.1.1" 592 | source = "registry+https://github.com/rust-lang/crates.io-index" 593 | 594 | [[package]] 595 | name = "syn" 596 | version = "0.13.11" 597 | source = "registry+https://github.com/rust-lang/crates.io-index" 598 | dependencies = [ 599 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 600 | "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 601 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 602 | ] 603 | 604 | [[package]] 605 | name = "syn" 606 | version = "0.15.29" 607 | source = "registry+https://github.com/rust-lang/crates.io-index" 608 | dependencies = [ 609 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 610 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 611 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 612 | ] 613 | 614 | [[package]] 615 | name = "typenum" 616 | version = "1.10.0" 617 | source = "registry+https://github.com/rust-lang/crates.io-index" 618 | 619 | [[package]] 620 | name = "uarte-logger" 621 | version = "0.1.0" 622 | dependencies = [ 623 | "nrf52832-hal 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", 624 | ] 625 | 626 | [[package]] 627 | name = "uhr" 628 | version = "0.2.0" 629 | dependencies = [ 630 | "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", 631 | "generic-array 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", 632 | "gregor 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 633 | "heapless 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", 634 | ] 635 | 636 | [[package]] 637 | name = "unicode-xid" 638 | version = "0.1.0" 639 | source = "registry+https://github.com/rust-lang/crates.io-index" 640 | 641 | [[package]] 642 | name = "utils" 643 | version = "0.1.0" 644 | dependencies = [ 645 | "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 646 | "nrf52832-hal 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", 647 | ] 648 | 649 | [[package]] 650 | name = "vcell" 651 | version = "0.1.0" 652 | source = "registry+https://github.com/rust-lang/crates.io-index" 653 | 654 | [[package]] 655 | name = "void" 656 | version = "1.0.2" 657 | source = "registry+https://github.com/rust-lang/crates.io-index" 658 | 659 | [[package]] 660 | name = "volatile-register" 661 | version = "0.2.0" 662 | source = "registry+https://github.com/rust-lang/crates.io-index" 663 | dependencies = [ 664 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 665 | ] 666 | 667 | [metadata] 668 | "checksum aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d39da9b88ae1a81c03c9c082b8db83f1d0e93914126041962af61034ab44c4a5" 669 | "checksum aligned 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a316c7ea8e1e9ece54862c992def5a7ac14de9f5832b69d71760680efeeefa" 670 | "checksum as-slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "293dac66b274fab06f95e7efb05ec439a6b70136081ea522d270bc351ae5bb27" 671 | "checksum bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3caf393d93b2d453e80638d0674597020cef3382ada454faacd43d1a55a735a" 672 | "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" 673 | "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" 674 | "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" 675 | "checksum cortex-m 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0b159a1e8306949579de3698c841dba58058197b65c60807194e4fa1e7a554" 676 | "checksum cortex-m 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f3c18719fdc57db65668bfc977db9a0fa1a41d718c5d9cd4f652c9d4b0e0956a" 677 | "checksum cortex-m-rt 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7e1ccc9052352415ec4e3f762f4541098d012016f9354a1a5b2dede39b67f426" 678 | "checksum cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d7ae692573e0acccb1579fef1abf5a5bf1d2f3f0149a22b16870ec9309aee25f" 679 | "checksum cortex-m-rtfm 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fb1d7afa5da773bf144e92e4ff886b4ed252e767e2cc729880fb55b515606bc1" 680 | "checksum cortex-m-rtfm-macros 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eb5caeeb7e8309eee746142f875b0edc125761ccaab2c6b991414e89ca58c444" 681 | "checksum cortex-m-semihosting 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1dc2abec1a772e8bb697cad17d5710f180043caf8939820f0f6ba4b7ae2a4b5" 682 | "checksum dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f77c3702f744259a3546f52a93b0818cb8ef35e8f2d5ae2fbc26ebdfcb79f31" 683 | "checksum dw1000 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "769c0db3ac502ca14835ee1908d2d831687a7e9f8e3ec0603364d53388c47432" 684 | "checksum dwm1001 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5b9b30a132752b1550fd88f09001d86a9fadf1d20cd248b6e1350feb970715d5" 685 | "checksum dwm1001 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0648e8d35055000b980ce011b655b64ba25a0cc6c4cc02444e42e3f6653a35e0" 686 | "checksum embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9880e55238830314d41d88f1ac7a819d495799c3cc3bc392cc172bab26428c33" 687 | "checksum embedded-timeout-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "429baa10dbdb9bac80064bbc69e2bb3ca8d9924ef29c59c51483da3615eee8ee" 688 | "checksum encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" 689 | "checksum fpa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f074479d683e5a8fd0bf1251d0a5d91b0d9178b867b44962191ed0eaaf8d4009" 690 | "checksum generic-array 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8107dafa78c80c848b71b60133954b4a58609a3a1a5f9af037ecc7f67280f369" 691 | "checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" 692 | "checksum gregor 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "de4ee4a087922af7d55ecbcd41a95cc79b40844924bec1af547b75773d22397a" 693 | "checksum hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12d790435639c06a7b798af9e1e331ae245b7ef915b92f70a39b4cf8c00686af" 694 | "checksum hash32-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebc0efbd154a17cddc3616d83faef479c0076d871a2143c157b310cc7ca799a2" 695 | "checksum heapless 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "82b7c5c8d508f4fc7db5dcc045029962dedf7a2b15bf4371044bfff62ef73c37" 696 | "checksum ieee802154 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca800ffd69f7a11ecd8d13637603f5f227aac6e4c94e37cbecdaf63dfedbe4a" 697 | "checksum ieee802154 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af632b4000a49093d3612d43529b9847a45690168dbe1f0877b8535e0670d281" 698 | "checksum nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b1411551beb3c11dedfb0a90a0fa256b47d28b9ec2cdff34c25a2fa59e45dbdc" 699 | "checksum nrf52-hal-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3de7d61b88c3f51a6d98207ae96a19556660d1f22e77b53f73eeff83cd4ff26e" 700 | "checksum nrf52-hal-common 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03dcdf72cd52a1c4829905e08a90ad6f4dc0f9d15ecf1883cc74f098199aa873" 701 | "checksum nrf52832-hal 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "357ea63c48c9aa63d07e92262ceab0904697f61775a69a966ff0e33f259a3989" 702 | "checksum nrf52832-hal 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4803f1d08e6a4c8726ae68b40cecf7c2ab05f49b1ce29af932d052cb61114c" 703 | "checksum nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "979c2317388354d7dfc55c7b5098fd6becbb3ea588c7da627f2dcbcfd46a94bf" 704 | "checksum nrf52832-pac 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c4545414415bddd872f13c0a5418ecc380e34347a52cb048cfed38c1b0957fa" 705 | "checksum owned-singleton 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21aa378869c97c7db706a4c576cf0ce8258dc7e0e1ad25a97ee5aba1fd4eed83" 706 | "checksum owned-singleton-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d5c2ac071b95017bf70a5b607037fb0ef4abfa663fdf6cac8fbf36af9756ee3" 707 | "checksum panic-ramdump 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f979b14fb579cccb599e38dbc96fdd8847eec2eac80b5dd9ed27f8be3e918c14" 708 | "checksum postcard 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6273e29a04e467f6a575d7d7430811607efb9df02b456903cb0717df98104664" 709 | "checksum postcard-cobs 0.1.5-pre (registry+https://github.com/rust-lang/crates.io-index)" = "7c68cb38ed13fd7bc9dd5db8f165b7c8d9c1a315104083a2b10f11354c2af97f" 710 | "checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7" 711 | "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" 712 | "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8" 713 | "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" 714 | "checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" 715 | "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" 716 | "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 717 | "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" 718 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 719 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 720 | "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 721 | "checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" 722 | "checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" 723 | "checksum ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" 724 | "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" 725 | "checksum syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b" 726 | "checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2" 727 | "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" 728 | "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" 729 | "checksum vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45c297f0afb6928cd08ab1ff9d95e99392595ea25ae1b5ecf822ff8764e57a0d" 730 | "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 731 | "checksum volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" 732 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | members = [ 4 | "sensor-node", 5 | "uarte-logger", 6 | 7 | # Proof of Concepts 8 | "pocs/rtc-poc", 9 | "pocs/sparkfun-7seg", 10 | 11 | "uhr", 12 | "utils", 13 | "protocol", 14 | "nrf52-hal-backports", 15 | ] 16 | 17 | [profile.release] 18 | opt-level = 's' 19 | debug = true 20 | lto = true 21 | incremental = false 22 | codegen-units = 1 23 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Ferrous Systems GmbH 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Internet of Streams Project 2 | 3 | Building a wireless sensor platform from (almost) scratch in Embedded Rust. Built with a focus on teaching embedded systems, IoT development, and Rust through live streamed coding sessions. Devices based on the [DWM1001-DEV] board, the [Nordic nRF52] microcontroller, and [Embedded Rust]. 4 | 5 | [DWM1001-DEV]: https://www.decawave.com/product/dwm1001-development-board/ 6 | [Embedded Rust]: https://github.com/rust-embedded/wg 7 | [Nordic nRF52]: https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52832 8 | 9 | This project is sponsored by [Ferrous Systems](https://ferrous-systems.com). Interested in trainings or consulting on Embedded Systems, IoT projects, or the Rust Programming Language? [Get in touch!](mailto:iot-streams@ferrous-systems.com) 10 | 11 | [![Ferrous Systems](https://ferrous-systems.com/images/ferrous-logo-text.svg)](https://ferrous-systems.com/) 12 | 13 | ## Stream Videos 14 | 15 | You can find a [playlist of all videos here](https://www.youtube.com/playlist?list=PLX44HkctSkTewrL9frlUz0yeKLKecebT1) on YouTube. 16 | 17 | * [2019-02-23] - **Hello Blinky World!** 18 | * Get the project set up 19 | * Get CI set up 20 | * Get HAL and RTFM set up 21 | * Blink the first LED 22 | * [2019-02-28] - **COBS Encoding for Serial Framing** 23 | * Finish up a PR to get a streaming COBS encoder 24 | * [2019-03-02] - **Async DMA UARTE - Part 1** 25 | * Get nrf52-hal vendored 26 | * Update some old code 27 | * Try to work around RTFM limitations 28 | * see the `uarte` branch for WIP 29 | * [2019-03-07] - **Simple Blocking UART Logger** 30 | * Send data over the UART 31 | * Provide log/warn/err levels 32 | * Send data larger than a single 255 byte transaction 33 | * [2019-03-10] - **Radio Work and `no_std` Serde** 34 | * Get messages sending periodically 35 | * Receive incoming messages 36 | * Use the hardware random number generator 37 | * Serialize/Deserialize messages with `ssmarshal` and `serde` 38 | * [2019-03-17] - **Workspace Cleanup and Alarm Clock Planning** 39 | * Discuss making an alarm clock as a first device 40 | * Discuss RTCs and how they work 41 | * Refactor the repo into a workspace 42 | * [2019-03-20] - **Real Time Clock - Part 1** 43 | * Start implementing the nRF52 RTC peripheral 44 | * Write a low level peripheral driver 45 | * Add an interrupt handler to RTFM 46 | * Got stuck due to some code problems 47 | * [2019-03-28] - **Real Time Clock - Part 2** 48 | * Debugging a low level peripheral driver 49 | * Investigating what went wrong 50 | * Got the RTC interrupt working properly! 51 | * [2019-03-31] - **Making an Alarm Clock - Part 1** 52 | * Reviewed the [`uhr` crate] for tracking wall time and alarms 53 | * Implemented a (re-)scheduler to allow alarms to repeat on a fixed weekly schedule 54 | * Wrote a no_std unit test for verifying an optimized bit-math algorithm 55 | 56 | [2019-02-23]: https://youtu.be/S0VI70nY6Vo 57 | [2019-02-28]: https://youtu.be/mnPbmPqKf1s 58 | [2019-03-02]: https://youtu.be/O6KeMpnLRkI 59 | [2019-03-07]: https://youtu.be/WYIei1MpVe4 60 | [2019-03-10]: https://youtu.be/U2rC24XGtTk 61 | [2019-03-17]: https://youtu.be/Qaa_p0K_B84 62 | [2019-03-20]: https://youtu.be/_M0AYdWKnzw 63 | [2019-03-28]: https://youtu.be/UB8OiEFdYgQ 64 | [2019-03-31]: https://youtu.be/CGJNQR1rj9Q 65 | 66 | [`uhr` crate]: https://crates.io/crates/uhr 67 | 68 | ## Future Topics 69 | 70 | The following topics are planned to be addressed in future streams: 71 | 72 | * Wireless Communication 73 | * Bootloader/OTA updates 74 | * Low Power Mode 75 | * Logging 76 | * Unit Testing 77 | * Hardware in the Loop testing 78 | * 6LoWPAN 79 | * Bluetooth 80 | * Gateway Router 81 | * Messaging/Protocol/Serialization/Deserialization 82 | * LED status codes 83 | 84 | ## License 85 | 86 | Licensed under either of 87 | 88 | - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or 89 | http://www.apache.org/licenses/LICENSE-2.0) 90 | - MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 91 | 92 | at your option. 93 | 94 | ### Contribution 95 | 96 | Unless you explicitly state otherwise, any contribution intentionally submitted 97 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall be 98 | dual licensed as above, without any additional terms or conditions. 99 | -------------------------------------------------------------------------------- /notes/2019-03-17.md: -------------------------------------------------------------------------------- 1 | # TO-DO 2 | 3 | * Switch to my fork of dwm1001 4 | * Make projects 5 | * Gateway Router Modem 6 | * Scratch Sensor Node 7 | * Alarm Clock 8 | * Looking at either: 9 | * PWM 10 | * RTC 11 | 12 | 13 | ## Misc rants 14 | 15 | - Gateway Router 16 | - Embedded Linux 17 | - Wi-Fi/Ethernet 18 | - Domain Specific Radio 19 | - Zigbee 20 | - 6LoWPAN 21 | - Bluetooth Mesh 22 | - 802.15.4 23 | - "Proprietary" 24 | 25 | - (W)PAN 26 | - 5-50m 27 | - WAN 28 | - 300m - 1km 29 | - [LoRA, NB-IoT] 30 | - 10-100s km 31 | -------------------------------------------------------------------------------- /notes/2019-03-31.md: -------------------------------------------------------------------------------- 1 | # TODO for myself 2 | 3 | * Implement some kind of alarm schedule 4 | * Weekly 5 | * Weekday 6 | * Weekend 7 | * NTP-lite 8 | * Something to receive the new time 9 | * Something to send the new time 10 | 11 | 12 | 13 | 14 | * NETWORK 15 | * Single Server 16 | * "passthrough modem" 17 | * Protocol over UART for TX/RX 18 | * Framing COBS 19 | * server side client 20 | * Modem Comms thread 21 | * Web server (UI/REST) to interact with network 22 | * All my nodes 23 | * Process messages 24 | * Both need: 25 | * Protocol 26 | -------------------------------------------------------------------------------- /notes/alarm-clock.md: -------------------------------------------------------------------------------- 1 | # Making an alarm clock 2 | 3 | * What do I need for this 4 | * Keep time 5 | * nRF52 RTC 6 | * Not implemented :( 7 | * Check back for fine tuning 8 | * message protocol for setting/getting time 9 | * "Local" NTP 10 | * Seting an alarm 11 | * Remotely set an alarm(s) 12 | * Remotely get set alarm(s) 13 | * Polyphonic 14 | * Ability to drive some kind of alarm 15 | * Piezo buzzer 16 | * Maybe something bigger 17 | * PWM 18 | * Not implemented :( 19 | * Some kind of screen 20 | * 16x2 character display 21 | * HD44780 22 | * Low Power Mode 23 | * Power states 24 | 25 | __ __ 26 | __| |__| | 27 | -------------------------------------------------------------------------------- /notes/misc.md: -------------------------------------------------------------------------------- 1 | # Notes 2 | 3 | * $(whoami) 4 | * James Munns 5 | * Ferrous Systems 6 | * What is this/Goals? 7 | * Wireless Sensor Node 8 | * Single Side Project 9 | * Showcase of what is possible in embedded rust 10 | * Showcase of the existing libraries in rust 11 | * Focus on teaching: 12 | * Embedded 13 | * Rust Language 14 | * IoT development 15 | * DWM-1001-DEV 16 | * https://www.decawave.com/product/dwm1001-development-board/ 17 | * Rust Libraries 18 | * https://github.com/braun-robotics/rust-dwm1001 19 | * https://github.com/nrf-rs/nrf52-hal 20 | * https://github.com/japaric/cortex-m-rtfm 21 | * Project link 22 | * HTTP: https://github.com/ferrous-systems/internet-of-streams 23 | * git: git@github.com:ferrous-systems/internet-of-streams.git 24 | 25 | # Things to do (eventually) 26 | 27 | * Wireless Communication 28 | * Bootloader/OTA updates 29 | * Low Power Mode 30 | * Logging 31 | * Unit Testing 32 | * Hardware in the Loop testing 33 | * 6LoWPAN 34 | * Bluetooth 35 | * Gateway Router 36 | * Messaging/Protocol/Serialization/Deserialization 37 | 38 | # Things already done 39 | 40 | * 2019-02-23 41 | * Get the project set up 42 | * Get CI set up 43 | * Get HAL and RTFM set up 44 | * Blink the first LED 45 | 46 | # Things to do today 47 | 48 | * Get COBS working 49 | * Get UARTE working 50 | -------------------------------------------------------------------------------- /nrf52-hal-backports/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nrf52-hal-backports" 3 | version = "0.1.0" 4 | authors = ["James Munns "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | nrf52832-pac = "0.6.0" 9 | cortex-m = "*" 10 | embedded-hal = "0.2.2" 11 | 12 | [dependencies.cast] 13 | version = "0.2" 14 | default-features = false 15 | -------------------------------------------------------------------------------- /nrf52-hal-backports/src/clocks.rs: -------------------------------------------------------------------------------- 1 | //! Configuration and control of the High and Low Frequency Clock 2 | //! sources 3 | 4 | #![allow(dead_code)] 5 | 6 | use nrf52832_pac::CLOCK; 7 | 8 | // ZST Type States 9 | 10 | /// Internal/RC Oscillator 11 | pub struct Internal; 12 | 13 | /// External Crystal Oscillator 14 | pub struct ExternalOscillator; 15 | 16 | /// Low Frequency Clock synthesize from High Frequency Clock 17 | pub struct LfOscSynthesized; 18 | 19 | /// Low Frequency Clock Started 20 | pub struct LfOscStarted; 21 | 22 | /// Low Frequency Clock Stopped 23 | pub struct LfOscStopped; 24 | 25 | /// Extension trait for the CLOCK peripheral 26 | pub trait ClocksExt { 27 | fn constrain(self) -> Clocks; 28 | } 29 | 30 | /// High Frequency Clock Frequency (in Hz) 31 | pub const HFCLK_FREQ: u32 = 64_000_000; 32 | /// Low Frequency Clock Frequency (in Hz) 33 | pub const LFCLK_FREQ: u32 = 32_768; 34 | 35 | /// A high level abstraction for the CLOCK peripheral 36 | pub struct Clocks { 37 | hfclk: H, 38 | lfclk: L, 39 | lfstat: LSTAT, 40 | periph: CLOCK, 41 | } 42 | 43 | impl Clocks { 44 | /// Use an external oscillator as the high frequency clock source 45 | pub fn enable_ext_hfosc(self) -> Clocks { 46 | self.periph.tasks_hfclkstart.write(|w| unsafe { w.bits(1) }); 47 | 48 | // Datasheet says this is likely to take 0.36ms 49 | while self.periph.events_hfclkstarted.read().bits() != 1 {} 50 | self.periph.events_hfclkstarted.write(|w| unsafe { w.bits(0) }); 51 | 52 | Clocks { 53 | hfclk: ExternalOscillator, 54 | lfclk: self.lfclk, 55 | lfstat: self.lfstat, 56 | periph: self.periph, 57 | } 58 | } 59 | 60 | /// Use the internal oscillator as the high frequency clock source 61 | pub fn disable_ext_hfosc(self) -> Clocks { 62 | self.periph.tasks_hfclkstop.write(|w| unsafe { w.bits(1) }); 63 | Clocks { 64 | hfclk: Internal, 65 | lfclk: self.lfclk, 66 | lfstat: self.lfstat, 67 | periph: self.periph, 68 | } 69 | } 70 | 71 | /// Stop the Low Frequency clock 72 | pub fn stop_lfclk(self) -> Clocks { 73 | self.periph.tasks_lfclkstop.write(|w| unsafe { w.bits(1) }); 74 | Clocks { 75 | hfclk: self.hfclk, 76 | lfclk: self.lfclk, 77 | lfstat: LfOscStopped, 78 | periph: self.periph, 79 | } 80 | } 81 | 82 | /// Start the Low Frequency clock 83 | pub fn start_lfclk(self) -> Clocks { 84 | self.periph.tasks_lfclkstart.write(|w| unsafe { w.bits(1) }); 85 | 86 | // Datasheet says this could take 100us from synth source 87 | // 600us from rc source, 0.25s from an external source 88 | while self.periph.events_lfclkstarted.read().bits() != 1 {} 89 | self.periph.events_lfclkstarted.write(|w| unsafe { w.bits(0) }); 90 | 91 | Clocks { 92 | hfclk: self.hfclk, 93 | lfclk: self.lfclk, 94 | lfstat: LfOscStarted, 95 | periph: self.periph, 96 | } 97 | } 98 | } 99 | 100 | /// Allowable configuration options for the low frequency oscillator when 101 | /// driven fron an external crystal 102 | pub enum LfOscConfiguration { 103 | NoExternalNoBypass, 104 | ExternalNoBypass, 105 | ExternalAndBypass, 106 | } 107 | 108 | impl Clocks { 109 | /// Use the internal RC Oscillator for the low frequency clock source 110 | pub fn set_lfclk_src_rc(self) -> Clocks { 111 | self.periph.lfclksrc.write(|w| { 112 | w.src().rc() 113 | .bypass().disabled() 114 | .external().disabled() 115 | }); 116 | Clocks { 117 | hfclk: self.hfclk, 118 | lfclk: Internal, 119 | lfstat: self.lfstat, 120 | periph: self.periph, 121 | } 122 | } 123 | 124 | /// Generate the Low Frequency clock from the high frequency clock source 125 | pub fn set_lfclk_src_synth(self) -> Clocks { 126 | self.periph.lfclksrc.write(|w| { 127 | w.src().synth() 128 | .bypass().disabled() 129 | .external().disabled() 130 | }); 131 | Clocks { 132 | hfclk: self.hfclk, 133 | lfclk: LfOscSynthesized, 134 | lfstat: self.lfstat, 135 | periph: self.periph, 136 | } 137 | } 138 | 139 | /// Use an external crystal to drive the low frequency clock 140 | pub fn set_lfclk_src_external(self, cfg: LfOscConfiguration) -> Clocks { 141 | let (ext, byp) = match cfg { 142 | LfOscConfiguration::NoExternalNoBypass => (false, false), 143 | LfOscConfiguration::ExternalNoBypass => (true, false), 144 | LfOscConfiguration::ExternalAndBypass => (true, true), 145 | }; 146 | self.periph.lfclksrc.write(move |w| { 147 | w.src().xtal() 148 | .bypass().bit(byp) 149 | .external().bit(ext) 150 | }); 151 | Clocks { 152 | hfclk: self.hfclk, 153 | lfclk: ExternalOscillator, 154 | lfstat: self.lfstat, 155 | periph: self.periph, 156 | } 157 | } 158 | } 159 | 160 | impl ClocksExt for CLOCK { 161 | fn constrain(self) -> Clocks { 162 | Clocks { 163 | hfclk: Internal, 164 | lfclk: Internal, 165 | lfstat: LfOscStopped, 166 | periph: self, 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /nrf52-hal-backports/src/delay.rs: -------------------------------------------------------------------------------- 1 | //! Delays 2 | 3 | #![allow(dead_code)] 4 | 5 | use cast::u32; 6 | use nrf52832_pac::SYST; 7 | use cortex_m::peripheral::syst::SystClkSource; 8 | use embedded_hal::blocking::delay::{DelayMs, DelayUs}; 9 | 10 | use crate::clocks::HFCLK_FREQ; 11 | 12 | /// System timer (SysTick) as a delay provider 13 | pub struct Delay { 14 | syst: SYST, 15 | } 16 | 17 | impl Delay { 18 | /// Configures the system timer (SysTick) as a delay provider 19 | pub fn new(mut syst: SYST) -> Self { 20 | syst.set_clock_source(SystClkSource::Core); 21 | 22 | Delay { syst } 23 | } 24 | 25 | /// Releases the system timer (SysTick) resource 26 | pub fn free(self) -> SYST { 27 | self.syst 28 | } 29 | } 30 | 31 | impl DelayMs for Delay { 32 | fn delay_ms(&mut self, ms: u32) { 33 | self.delay_us(ms * 1_000); 34 | } 35 | } 36 | 37 | impl DelayMs for Delay { 38 | fn delay_ms(&mut self, ms: u16) { 39 | self.delay_ms(u32(ms)); 40 | } 41 | } 42 | 43 | impl DelayMs for Delay { 44 | fn delay_ms(&mut self, ms: u8) { 45 | self.delay_ms(u32(ms)); 46 | } 47 | } 48 | 49 | impl DelayUs for Delay { 50 | fn delay_us(&mut self, us: u32) { 51 | // The SysTick Reload Value register supports values between 1 and 0x00FFFFFF. 52 | const MAX_RVR: u32 = 0x00FF_FFFF; 53 | 54 | let mut total_rvr = us * (HFCLK_FREQ / 1_000_000); 55 | 56 | while total_rvr != 0 { 57 | let current_rvr = if total_rvr <= MAX_RVR { 58 | total_rvr 59 | } else { 60 | MAX_RVR 61 | }; 62 | 63 | self.syst.set_reload(current_rvr); 64 | self.syst.clear_current(); 65 | self.syst.enable_counter(); 66 | 67 | // Update the tracking variable while we are waiting... 68 | total_rvr -= current_rvr; 69 | 70 | while !self.syst.has_wrapped() {} 71 | 72 | self.syst.disable_counter(); 73 | } 74 | } 75 | } 76 | 77 | impl DelayUs for Delay { 78 | fn delay_us(&mut self, us: u16) { 79 | self.delay_us(u32(us)) 80 | } 81 | } 82 | 83 | impl DelayUs for Delay { 84 | fn delay_us(&mut self, us: u8) { 85 | self.delay_us(u32(us)) 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /nrf52-hal-backports/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | pub mod clocks; 3 | pub mod delay; 4 | pub mod rtc; 5 | -------------------------------------------------------------------------------- /nrf52-hal-backports/src/rtc.rs: -------------------------------------------------------------------------------- 1 | //! A high level interface for RTC peripherals 2 | 3 | #![allow(dead_code)] 4 | 5 | use core::ops::Deref; 6 | 7 | use nrf52832_pac::{ 8 | rtc0, 9 | RTC0, 10 | RTC1, 11 | }; 12 | 13 | #[cfg(not(feature = "52810"))] 14 | use nrf52832_pac::{ 15 | RTC2, 16 | }; 17 | 18 | // Zero Size Type State structs 19 | 20 | /// The RTC has been stopped 21 | pub struct Stopped; 22 | /// The RTC has been started 23 | pub struct Started; 24 | 25 | /// An opaque high level interface to an RTC peripheral 26 | pub struct Rtc { 27 | periph: T, 28 | _mode: M, 29 | } 30 | 31 | /// An extension trait for constructing the high level interface 32 | pub trait RtcExt : Deref + Sized { 33 | fn constrain(self) -> Rtc; 34 | } 35 | 36 | macro_rules! impl_rtc_ext { 37 | ($($rtc:ty,)*) => { 38 | $( 39 | impl RtcExt for $rtc { 40 | fn constrain(self) -> Rtc<$rtc, Stopped> { 41 | Rtc { 42 | periph: self, 43 | _mode: Stopped, 44 | } 45 | } 46 | } 47 | )* 48 | } 49 | } 50 | 51 | impl_rtc_ext!( 52 | RTC0, 53 | RTC1, 54 | ); 55 | 56 | #[cfg(not(feature = "52810"))] 57 | impl_rtc_ext!( 58 | RTC2, 59 | ); 60 | 61 | /// Interrupts/Events that can be generated by the RTCn peripheral 62 | pub enum RtcInterrupt { 63 | Tick, 64 | Overflow, 65 | Compare0, 66 | Compare1, 67 | Compare2, 68 | Compare3, 69 | } 70 | 71 | /// Compare registers available on the RTCn 72 | pub enum RtcCompareReg { 73 | Compare0, 74 | Compare1, 75 | Compare2, 76 | Compare3, 77 | } 78 | 79 | impl Rtc where T: RtcExt { 80 | /// Enable/start the Real Time Counter 81 | pub fn enable_counter(self) -> Rtc { 82 | unsafe { 83 | self.periph.tasks_start.write(|w| w.bits(1)); 84 | } 85 | Rtc { 86 | periph: self.periph, 87 | _mode: Started, 88 | } 89 | } 90 | 91 | /// Disable/stop the Real Time Counter 92 | pub fn disable_counter(self) -> Rtc { 93 | unsafe { 94 | self.periph.tasks_stop.write(|w| w.bits(1)); 95 | } 96 | Rtc { 97 | periph: self.periph, 98 | _mode: Stopped, 99 | } 100 | } 101 | 102 | /// Enable the generation of a hardware interrupt from a given stimulus 103 | pub fn enable_interrupt(&mut self, int: RtcInterrupt) { 104 | match int { 105 | RtcInterrupt::Tick => self.periph.intenset.write(|w| w.tick().set()), 106 | RtcInterrupt::Overflow => self.periph.intenset.write(|w| w.ovrflw().set()), 107 | RtcInterrupt::Compare0 => self.periph.intenset.write(|w| w.compare0().set()), 108 | RtcInterrupt::Compare1 => self.periph.intenset.write(|w| w.compare1().set()), 109 | RtcInterrupt::Compare2 => self.periph.intenset.write(|w| w.compare2().set()), 110 | RtcInterrupt::Compare3 => self.periph.intenset.write(|w| w.compare3().set()), 111 | } 112 | } 113 | 114 | /// Disable the generation of a hardware interrupt from a given stimulus 115 | pub fn disable_interrupt(&mut self, int: RtcInterrupt) { 116 | match int { 117 | RtcInterrupt::Tick => self.periph.intenclr.write(|w| w.tick().clear()), 118 | RtcInterrupt::Overflow => self.periph.intenclr.write(|w| w.ovrflw().clear()), 119 | RtcInterrupt::Compare0 => self.periph.intenclr.write(|w| w.compare0().clear()), 120 | RtcInterrupt::Compare1 => self.periph.intenclr.write(|w| w.compare1().clear()), 121 | RtcInterrupt::Compare2 => self.periph.intenclr.write(|w| w.compare2().clear()), 122 | RtcInterrupt::Compare3 => self.periph.intenclr.write(|w| w.compare3().clear()), 123 | } 124 | } 125 | 126 | /// Enable the generation of a hardware event from a given stimulus 127 | pub fn enable_event(&mut self, evt: RtcInterrupt) { 128 | match evt { 129 | RtcInterrupt::Tick => self.periph.evtenset.write(|w| w.tick().set()), 130 | RtcInterrupt::Overflow => self.periph.evtenset.write(|w| w.ovrflw().set()), 131 | RtcInterrupt::Compare0 => self.periph.evtenset.write(|w| w.compare0().set()), 132 | RtcInterrupt::Compare1 => self.periph.evtenset.write(|w| w.compare1().set()), 133 | RtcInterrupt::Compare2 => self.periph.evtenset.write(|w| w.compare2().set()), 134 | RtcInterrupt::Compare3 => self.periph.evtenset.write(|w| w.compare3().set()), 135 | } 136 | } 137 | 138 | /// Disables the generation of a hardware event from a given stimulus 139 | pub fn disable_event(&mut self, evt: RtcInterrupt) { 140 | match evt { 141 | RtcInterrupt::Tick => self.periph.evtenclr.write(|w| w.tick().clear()), 142 | RtcInterrupt::Overflow => self.periph.evtenclr.write(|w| w.ovrflw().clear()), 143 | RtcInterrupt::Compare0 => self.periph.evtenclr.write(|w| w.compare0().clear()), 144 | RtcInterrupt::Compare1 => self.periph.evtenclr.write(|w| w.compare1().clear()), 145 | RtcInterrupt::Compare2 => self.periph.evtenclr.write(|w| w.compare2().clear()), 146 | RtcInterrupt::Compare3 => self.periph.evtenclr.write(|w| w.compare3().clear()), 147 | } 148 | } 149 | 150 | /// Obtain the state of a given interrupt/event, and optionally clear the event 151 | /// if it is set 152 | pub fn get_event_triggered(&mut self, evt: RtcInterrupt, clear_on_read: bool) -> bool { 153 | let mut orig = 0; 154 | let set_val = if clear_on_read { 0 } else { 1 }; 155 | match evt { 156 | RtcInterrupt::Tick => { 157 | self.periph.events_tick.modify(|r, w| { 158 | orig = r.bits(); 159 | unsafe { w.bits(set_val) } 160 | }) 161 | } 162 | RtcInterrupt::Overflow => { 163 | self.periph.events_ovrflw.modify(|r, w| { 164 | orig = r.bits(); 165 | unsafe { w.bits(set_val) } 166 | }) 167 | } 168 | RtcInterrupt::Compare0 => { 169 | self.periph.events_compare[0].modify(|r, w| { 170 | orig = r.bits(); 171 | unsafe { w.bits(set_val) } 172 | }) 173 | } 174 | RtcInterrupt::Compare1 => { 175 | self.periph.events_compare[1].modify(|r, w| { 176 | orig = r.bits(); 177 | unsafe { w.bits(set_val) } 178 | }) 179 | } 180 | RtcInterrupt::Compare2 => { 181 | self.periph.events_compare[2].modify(|r, w| { 182 | orig = r.bits(); 183 | unsafe { w.bits(set_val) } 184 | }) 185 | } 186 | RtcInterrupt::Compare3 => { 187 | self.periph.events_compare[3].modify(|r, w| { 188 | orig = r.bits(); 189 | unsafe { w.bits(set_val) } 190 | }) 191 | } 192 | }; 193 | 194 | orig == 1 195 | } 196 | 197 | /// Set the compare value of a given register. The compare registers have a width 198 | /// of 24 bits 199 | pub fn set_compare(&mut self, reg: RtcCompareReg, val: u32) -> Result<(), Error> { 200 | if val >= (1 << 24) { 201 | return Err(Error::CompareOutOfRange); 202 | } 203 | 204 | let reg = match reg { 205 | RtcCompareReg::Compare0 => 0, 206 | RtcCompareReg::Compare1 => 1, 207 | RtcCompareReg::Compare2 => 2, 208 | RtcCompareReg::Compare3 => 3, 209 | }; 210 | 211 | unsafe { self.periph.cc[reg].write(|w| w.bits(val)); } 212 | 213 | Ok(()) 214 | } 215 | 216 | /// Obtain the current value of the Real Time Counter, 24 bits of range 217 | pub fn get_counter(&self) -> u32 { 218 | self.periph.counter.read().bits() 219 | } 220 | 221 | /// Destructure the high level interface. Does not reset any configuration made 222 | /// to the given RTC peripheral 223 | pub fn release(self) -> T { 224 | self.periph 225 | } 226 | } 227 | 228 | /// Error types associated with the RTC peripheral interface 229 | #[derive(Debug, PartialEq, Eq)] 230 | pub enum Error { 231 | PrescalerOutOfRange, 232 | CompareOutOfRange, 233 | } 234 | 235 | impl Rtc where T: RtcExt { 236 | /// Set the prescaler for the RTC peripheral. 12 bits of range. 237 | /// fRTC = 32_768 / (`prescaler` + 1 ) 238 | pub fn set_prescaler(&mut self, prescaler: u32) -> Result<(), Error> { 239 | if prescaler >= (1 << 12) { 240 | return Err(Error::PrescalerOutOfRange); 241 | } 242 | 243 | unsafe { self.periph.prescaler.write(|w| w.bits(prescaler)) }; 244 | 245 | Ok(()) 246 | } 247 | } 248 | -------------------------------------------------------------------------------- /pocs/rtc-poc/Cargo.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "aligned" 3 | version = "0.2.0" 4 | source = "registry+https://github.com/rust-lang/crates.io-index" 5 | 6 | [[package]] 7 | name = "bare-metal" 8 | version = "0.2.4" 9 | source = "registry+https://github.com/rust-lang/crates.io-index" 10 | dependencies = [ 11 | "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 12 | ] 13 | 14 | [[package]] 15 | name = "byteorder" 16 | version = "1.3.1" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | 19 | [[package]] 20 | name = "cast" 21 | version = "0.2.2" 22 | source = "registry+https://github.com/rust-lang/crates.io-index" 23 | 24 | [[package]] 25 | name = "cortex-m" 26 | version = "0.5.8" 27 | source = "registry+https://github.com/rust-lang/crates.io-index" 28 | dependencies = [ 29 | "aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 30 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 31 | "volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 32 | ] 33 | 34 | [[package]] 35 | name = "cortex-m-rt" 36 | version = "0.6.7" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | dependencies = [ 39 | "cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 40 | "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 41 | ] 42 | 43 | [[package]] 44 | name = "cortex-m-rt-macros" 45 | version = "0.1.5" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | dependencies = [ 48 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 49 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 50 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 51 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 52 | ] 53 | 54 | [[package]] 55 | name = "cortex-m-rtfm" 56 | version = "0.4.1" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | dependencies = [ 59 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 60 | "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 61 | "cortex-m-rtfm-macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", 62 | "heapless 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 63 | "owned-singleton 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 64 | ] 65 | 66 | [[package]] 67 | name = "cortex-m-rtfm-macros" 68 | version = "0.4.1" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | dependencies = [ 71 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 72 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 73 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 74 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 75 | ] 76 | 77 | [[package]] 78 | name = "cortex-m-semihosting" 79 | version = "0.3.2" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | dependencies = [ 82 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 83 | ] 84 | 85 | [[package]] 86 | name = "dw1000" 87 | version = "0.1.0" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | dependencies = [ 90 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 91 | "ieee802154 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 92 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 93 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 94 | "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 95 | "ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 96 | ] 97 | 98 | [[package]] 99 | name = "dwm1001" 100 | version = "0.1.0" 101 | source = "git+https://github.com/braun-robotics/rust-dwm1001?rev=construct-by-parts#7574aee00133182d75809dd52b8d20b33cb0b581" 102 | dependencies = [ 103 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 104 | "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 105 | "cortex-m-semihosting 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 106 | "dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 107 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 108 | "nrf52832-hal 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 109 | ] 110 | 111 | [[package]] 112 | name = "embedded-hal" 113 | version = "0.2.2" 114 | source = "registry+https://github.com/rust-lang/crates.io-index" 115 | dependencies = [ 116 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 117 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 118 | ] 119 | 120 | [[package]] 121 | name = "encode_unicode" 122 | version = "0.3.5" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | 125 | [[package]] 126 | name = "generic-array" 127 | version = "0.11.1" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | dependencies = [ 130 | "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 131 | ] 132 | 133 | [[package]] 134 | name = "hash32" 135 | version = "0.1.0" 136 | source = "registry+https://github.com/rust-lang/crates.io-index" 137 | dependencies = [ 138 | "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 139 | ] 140 | 141 | [[package]] 142 | name = "hash32-derive" 143 | version = "0.1.0" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | dependencies = [ 146 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 147 | "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 148 | "syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)", 149 | ] 150 | 151 | [[package]] 152 | name = "heapless" 153 | version = "0.4.2" 154 | source = "registry+https://github.com/rust-lang/crates.io-index" 155 | dependencies = [ 156 | "generic-array 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", 157 | "hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 158 | ] 159 | 160 | [[package]] 161 | name = "ieee802154" 162 | version = "0.1.1" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | dependencies = [ 165 | "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 166 | "hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 167 | "hash32-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 168 | ] 169 | 170 | [[package]] 171 | name = "nb" 172 | version = "0.1.1" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | 175 | [[package]] 176 | name = "nrf52-hal-common" 177 | version = "0.7.0" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | dependencies = [ 180 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 181 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 182 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 183 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 184 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 185 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 186 | ] 187 | 188 | [[package]] 189 | name = "nrf52832-hal" 190 | version = "0.7.0" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | dependencies = [ 193 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 194 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 195 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 196 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 197 | "nrf52-hal-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 198 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 199 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 200 | ] 201 | 202 | [[package]] 203 | name = "nrf52832-pac" 204 | version = "0.6.0" 205 | source = "registry+https://github.com/rust-lang/crates.io-index" 206 | dependencies = [ 207 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 208 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 209 | "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 210 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 211 | ] 212 | 213 | [[package]] 214 | name = "owned-singleton" 215 | version = "0.1.0" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | dependencies = [ 218 | "owned-singleton-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 219 | "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 220 | ] 221 | 222 | [[package]] 223 | name = "owned-singleton-macros" 224 | version = "0.1.0" 225 | source = "registry+https://github.com/rust-lang/crates.io-index" 226 | dependencies = [ 227 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 228 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 229 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 230 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 231 | ] 232 | 233 | [[package]] 234 | name = "panic-ramdump" 235 | version = "0.1.0" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | dependencies = [ 238 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 239 | ] 240 | 241 | [[package]] 242 | name = "proc-macro2" 243 | version = "0.3.8" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | dependencies = [ 246 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 247 | ] 248 | 249 | [[package]] 250 | name = "proc-macro2" 251 | version = "0.4.27" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | dependencies = [ 254 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 255 | ] 256 | 257 | [[package]] 258 | name = "quote" 259 | version = "0.5.2" 260 | source = "registry+https://github.com/rust-lang/crates.io-index" 261 | dependencies = [ 262 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 263 | ] 264 | 265 | [[package]] 266 | name = "quote" 267 | version = "0.6.11" 268 | source = "registry+https://github.com/rust-lang/crates.io-index" 269 | dependencies = [ 270 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 271 | ] 272 | 273 | [[package]] 274 | name = "r0" 275 | version = "0.2.2" 276 | source = "registry+https://github.com/rust-lang/crates.io-index" 277 | 278 | [[package]] 279 | name = "rand" 280 | version = "0.5.6" 281 | source = "registry+https://github.com/rust-lang/crates.io-index" 282 | dependencies = [ 283 | "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 284 | ] 285 | 286 | [[package]] 287 | name = "rand_core" 288 | version = "0.3.1" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | dependencies = [ 291 | "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 292 | ] 293 | 294 | [[package]] 295 | name = "rand_core" 296 | version = "0.4.0" 297 | source = "registry+https://github.com/rust-lang/crates.io-index" 298 | 299 | [[package]] 300 | name = "rustc_version" 301 | version = "0.2.3" 302 | source = "registry+https://github.com/rust-lang/crates.io-index" 303 | dependencies = [ 304 | "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 305 | ] 306 | 307 | [[package]] 308 | name = "semver" 309 | version = "0.9.0" 310 | source = "registry+https://github.com/rust-lang/crates.io-index" 311 | dependencies = [ 312 | "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 313 | ] 314 | 315 | [[package]] 316 | name = "semver-parser" 317 | version = "0.7.0" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | 320 | [[package]] 321 | name = "sensor-node" 322 | version = "0.1.0" 323 | dependencies = [ 324 | "cortex-m-rtfm 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", 325 | "dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 326 | "dwm1001 0.1.0 (git+https://github.com/braun-robotics/rust-dwm1001?rev=construct-by-parts)", 327 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 328 | "heapless 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 329 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 330 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 331 | "panic-ramdump 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 332 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 333 | "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 334 | "ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 335 | ] 336 | 337 | [[package]] 338 | name = "serde" 339 | version = "1.0.85" 340 | source = "registry+https://github.com/rust-lang/crates.io-index" 341 | 342 | [[package]] 343 | name = "serde_derive" 344 | version = "1.0.85" 345 | source = "registry+https://github.com/rust-lang/crates.io-index" 346 | dependencies = [ 347 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 348 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 349 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 350 | ] 351 | 352 | [[package]] 353 | name = "ssmarshal" 354 | version = "1.0.0" 355 | source = "registry+https://github.com/rust-lang/crates.io-index" 356 | dependencies = [ 357 | "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 358 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 359 | ] 360 | 361 | [[package]] 362 | name = "stable_deref_trait" 363 | version = "1.1.1" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | 366 | [[package]] 367 | name = "syn" 368 | version = "0.13.11" 369 | source = "registry+https://github.com/rust-lang/crates.io-index" 370 | dependencies = [ 371 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 372 | "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 373 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 374 | ] 375 | 376 | [[package]] 377 | name = "syn" 378 | version = "0.15.26" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | dependencies = [ 381 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 382 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 383 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 384 | ] 385 | 386 | [[package]] 387 | name = "typenum" 388 | version = "1.10.0" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | 391 | [[package]] 392 | name = "unicode-xid" 393 | version = "0.1.0" 394 | source = "registry+https://github.com/rust-lang/crates.io-index" 395 | 396 | [[package]] 397 | name = "vcell" 398 | version = "0.1.0" 399 | source = "registry+https://github.com/rust-lang/crates.io-index" 400 | 401 | [[package]] 402 | name = "void" 403 | version = "1.0.2" 404 | source = "registry+https://github.com/rust-lang/crates.io-index" 405 | 406 | [[package]] 407 | name = "volatile-register" 408 | version = "0.2.0" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | dependencies = [ 411 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 412 | ] 413 | 414 | [metadata] 415 | "checksum aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d39da9b88ae1a81c03c9c082b8db83f1d0e93914126041962af61034ab44c4a5" 416 | "checksum bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3caf393d93b2d453e80638d0674597020cef3382ada454faacd43d1a55a735a" 417 | "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" 418 | "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" 419 | "checksum cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dab2164a0fc216781a47fc343347365112ae6917421d3fa4bac6faf0fbaaaec7" 420 | "checksum cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f69d2beca37acc3776c17201c9d1f8904fb9139fa3a4d2cf28c8436a07b21a88" 421 | "checksum cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d7ae692573e0acccb1579fef1abf5a5bf1d2f3f0149a22b16870ec9309aee25f" 422 | "checksum cortex-m-rtfm 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6b5c902cf9e63e346ac018f9462d30de7c502feab5351b3adca90cdd7771b74c" 423 | "checksum cortex-m-rtfm-macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40bb8b2e08acae1e0538bdc52168701c80bb8e8880c201507183190341261fea" 424 | "checksum cortex-m-semihosting 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1dc2abec1a772e8bb697cad17d5710f180043caf8939820f0f6ba4b7ae2a4b5" 425 | "checksum dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f77c3702f744259a3546f52a93b0818cb8ef35e8f2d5ae2fbc26ebdfcb79f31" 426 | "checksum dwm1001 0.1.0 (git+https://github.com/braun-robotics/rust-dwm1001?rev=construct-by-parts)" = "" 427 | "checksum embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9880e55238830314d41d88f1ac7a819d495799c3cc3bc392cc172bab26428c33" 428 | "checksum encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" 429 | "checksum generic-array 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8107dafa78c80c848b71b60133954b4a58609a3a1a5f9af037ecc7f67280f369" 430 | "checksum hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12d790435639c06a7b798af9e1e331ae245b7ef915b92f70a39b4cf8c00686af" 431 | "checksum hash32-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebc0efbd154a17cddc3616d83faef479c0076d871a2143c157b310cc7ca799a2" 432 | "checksum heapless 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "56b960caff1a46f1fb3c1eb05f0575ac21c6248364ebebde11b11116e099881c" 433 | "checksum ieee802154 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca800ffd69f7a11ecd8d13637603f5f227aac6e4c94e37cbecdaf63dfedbe4a" 434 | "checksum nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "69f380b5fe9fab8c0d7a6a99cda23e2cc0463bedb2cbc3aada0813b98496ecdc" 435 | "checksum nrf52-hal-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3de7d61b88c3f51a6d98207ae96a19556660d1f22e77b53f73eeff83cd4ff26e" 436 | "checksum nrf52832-hal 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "357ea63c48c9aa63d07e92262ceab0904697f61775a69a966ff0e33f259a3989" 437 | "checksum nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "979c2317388354d7dfc55c7b5098fd6becbb3ea588c7da627f2dcbcfd46a94bf" 438 | "checksum owned-singleton 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21aa378869c97c7db706a4c576cf0ce8258dc7e0e1ad25a97ee5aba1fd4eed83" 439 | "checksum owned-singleton-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d5c2ac071b95017bf70a5b607037fb0ef4abfa663fdf6cac8fbf36af9756ee3" 440 | "checksum panic-ramdump 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "699e5f8c3ae987deb02e8fea0099145f944b0d94b19efaa72d2d81484c908e4e" 441 | "checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7" 442 | "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" 443 | "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8" 444 | "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" 445 | "checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" 446 | "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" 447 | "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 448 | "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" 449 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 450 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 451 | "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 452 | "checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" 453 | "checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" 454 | "checksum ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" 455 | "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" 456 | "checksum syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b" 457 | "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" 458 | "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" 459 | "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" 460 | "checksum vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45c297f0afb6928cd08ab1ff9d95e99392595ea25ae1b5ecf822ff8764e57a0d" 461 | "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 462 | "checksum volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" 463 | -------------------------------------------------------------------------------- /pocs/rtc-poc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rtc-poc" 3 | version = "0.1.0" 4 | authors = ["James Munns "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | panic-ramdump = "0.1.0" 9 | nb = "0.1.1" 10 | cortex-m-rtfm = "0.4.1" 11 | nrf52832-pac = "0.6.0" 12 | dw1000 = "0.1.0" 13 | embedded-hal = "0.2.2" 14 | heapless = "0.4.2" 15 | cortex-m = "*" 16 | 17 | [dependencies.ssmarshal] 18 | version = "=1.0.0" 19 | default-features = false 20 | 21 | [dependencies.dwm1001] 22 | version = "0.1.1" 23 | features = [ "dev", "rt" ] 24 | 25 | [dependencies.cast] 26 | version = "0.2" 27 | default-features = false 28 | 29 | 30 | # Local workspace deps 31 | 32 | [dependencies.uarte-logger] 33 | path = "../../uarte-logger" 34 | 35 | [dependencies.utils] 36 | path = "../../utils" 37 | 38 | [dependencies.uhr] 39 | path = "../../uhr" 40 | 41 | [dependencies.protocol] 42 | path = "../../protocol" 43 | 44 | [dependencies.nrf52-hal-backports] 45 | path = "../../nrf52-hal-backports" 46 | -------------------------------------------------------------------------------- /pocs/rtc-poc/debug.gdb: -------------------------------------------------------------------------------- 1 | target remote :2331 2 | load 3 | mon reset 4 | # continue 5 | -------------------------------------------------------------------------------- /pocs/rtc-poc/src/main.rs: -------------------------------------------------------------------------------- 1 | #![no_main] 2 | #![no_std] 3 | 4 | // Built in dependencies 5 | use core::fmt::Write; 6 | 7 | // Crates.io dependencies 8 | use dw1000::{DW1000 as DW}; 9 | use dwm1001::{ 10 | self, 11 | nrf52832_hal::{ 12 | // delay::Delay, 13 | prelude::*, 14 | timer::Timer, 15 | gpio::{Pin, Output, PushPull, Level, p0::P0_17}, 16 | rng::Rng, 17 | spim::{Spim}, 18 | nrf52832_pac::{ 19 | TIMER0, 20 | SPIM2, 21 | RTC0 as RTC0_PERIPHERAL, 22 | }, 23 | }, 24 | new_dw1000, 25 | new_usb_uarte, 26 | UsbUarteConfig, 27 | DW_RST, 28 | }; 29 | use heapless::{String, consts::*}; 30 | use rtfm::app; 31 | 32 | // NOTE: Panic Provider 33 | use panic_ramdump as _; 34 | 35 | // NOTE: Must explicitly pull in for RTFM 36 | use nrf52832_pac; 37 | 38 | // Workspace dependencies 39 | use uarte_logger::Logger; 40 | 41 | use nrf52_hal_backports::{ 42 | clocks::{ 43 | ClocksExt, 44 | LfOscConfiguration 45 | }, 46 | rtc::{ 47 | Rtc, 48 | RtcExt, 49 | Started, 50 | RtcInterrupt 51 | }, 52 | delay::Delay, 53 | }; 54 | 55 | use uhr::{ 56 | Uhr, 57 | Wecker, 58 | FixedOffsetFromUtc, 59 | UnixTimestamp, 60 | DayFlags, 61 | }; 62 | 63 | use core::time::Duration; 64 | 65 | 66 | #[app(device = nrf52832_pac)] 67 | const APP: () = { 68 | static mut LED_RED_1: Pin> = (); 69 | static mut TIMER: Timer = (); 70 | static mut LOGGER: Logger = (); 71 | static mut DW1000: DW< 72 | Spim, 73 | P0_17>, 74 | dw1000::Ready, 75 | > = (); 76 | static mut DW_RST_PIN: DW_RST = (); 77 | static mut RANDOM: Rng = (); 78 | static mut RTCT: Rtc = (); 79 | static mut ALARM_CLOCK: Wecker = (); 80 | 81 | #[init] 82 | fn init() { 83 | let timer = device.TIMER0.constrain(); 84 | let pins = device.P0.split(); 85 | let uarte0 = new_usb_uarte( 86 | device.UARTE0, 87 | pins.p0_05, 88 | pins.p0_11, 89 | UsbUarteConfig::default(), 90 | ); 91 | 92 | let rng = device.RNG.constrain(); 93 | 94 | let dw1000 = new_dw1000( 95 | device.SPIM2, 96 | pins.p0_16, 97 | pins.p0_20, 98 | pins.p0_18, 99 | pins.p0_17, 100 | ); 101 | 102 | let mut rst_pin = DW_RST::new(pins.p0_24.into_floating_input()); 103 | 104 | // Start the clocks 105 | let _clocks = device 106 | .CLOCK 107 | .constrain() 108 | .enable_ext_hfosc() 109 | .set_lfclk_src_external(LfOscConfiguration::NoExternalNoBypass) 110 | .start_lfclk(); 111 | 112 | 113 | let mut delay = Delay::new(core.SYST); 114 | 115 | rst_pin.reset_dw1000(&mut delay); 116 | 117 | let dw1000 = dw1000.init().unwrap(); 118 | 119 | let mut rtc = RtcExt::constrain(device.RTC0); 120 | rtc.set_prescaler(0xFFF).unwrap(); 121 | rtc.enable_interrupt(RtcInterrupt::Tick); 122 | 123 | let mut alarm = Wecker::new(UnixTimestamp(1554041486)); 124 | 125 | // CEST 126 | alarm.time.set_local_time_zone(FixedOffsetFromUtc::from_hours_and_minutes(2, 0)); 127 | 128 | // alarm.alarms.push(Uhr::from(UnixTimestamp(1554041486 + 10))).unwrap(); 129 | 130 | let mut next_alarm = Uhr::from(UnixTimestamp(1554041486 + 10)); 131 | next_alarm.set_local_time_zone(FixedOffsetFromUtc::from_hours_and_minutes(2, 0)); 132 | 133 | alarm.insert_alarm(next_alarm, DayFlags::SUNDAY).unwrap(); 134 | // alarm.alarms.push(Uhr::from(UnixTimestamp(1554041486 + 25))).unwrap(); 135 | // alarm.alarms.push(Uhr::from(UnixTimestamp(1554041486 + 20))).unwrap(); 136 | // alarm.alarms.push(Uhr::from(UnixTimestamp(1554041486 + 10))).unwrap(); 137 | 138 | RTCT = rtc.enable_counter(); 139 | RANDOM = rng; 140 | DW_RST_PIN = rst_pin; 141 | DW1000 = dw1000; 142 | LOGGER = Logger::new(uarte0); 143 | TIMER = timer; 144 | LED_RED_1 = pins.p0_14.degrade().into_push_pull_output(Level::High); 145 | ALARM_CLOCK = alarm; 146 | } 147 | 148 | #[idle(resources = [TIMER, RANDOM, DW1000])] 149 | fn idle() -> ! { 150 | loop { 151 | cortex_m::asm::wfi(); 152 | } 153 | } 154 | 155 | #[interrupt(resources = [ALARM_CLOCK, RTCT, LED_RED_1, LOGGER])] 156 | fn RTC0() { 157 | static mut TOGG: bool = false; 158 | static mut STEP: u32 = 0; 159 | const TICK_TIME: &Duration = &Duration::from_millis(125); 160 | 161 | (*resources.RTCT).get_event_triggered(RtcInterrupt::Tick, true); 162 | 163 | if *TOGG { 164 | (*resources.LED_RED_1).set_low(); 165 | } else { 166 | (*resources.LED_RED_1).set_high(); 167 | } 168 | 169 | let mut out: String = String::new(); 170 | 171 | 172 | resources.ALARM_CLOCK.time.increment(TICK_TIME); 173 | if resources.ALARM_CLOCK.alarm_ready() { 174 | out.clear(); 175 | write!(&mut out, "!!! ALARM !!!").unwrap(); 176 | (*resources.LOGGER).error(&out).unwrap(); 177 | out.clear(); 178 | write!(&mut out, "{:?}", resources.ALARM_CLOCK).unwrap(); 179 | (*resources.LOGGER).log(&out).unwrap(); 180 | } 181 | 182 | if (*STEP & 0x7) == 0 { 183 | let time = resources.ALARM_CLOCK.time.into_local_date_time(); 184 | out.clear(); 185 | write!( 186 | &mut out, 187 | "TIME {:02}:{:02}:{:02}", 188 | time.hour(), 189 | time.minute(), 190 | time.second(), 191 | ).unwrap(); 192 | (*resources.LOGGER).log(&out).unwrap(); 193 | } 194 | 195 | *STEP += 1; 196 | *TOGG = !*TOGG; 197 | } 198 | }; 199 | -------------------------------------------------------------------------------- /pocs/sparkfun-7seg/Cargo.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "aligned" 3 | version = "0.2.0" 4 | source = "registry+https://github.com/rust-lang/crates.io-index" 5 | 6 | [[package]] 7 | name = "bare-metal" 8 | version = "0.2.4" 9 | source = "registry+https://github.com/rust-lang/crates.io-index" 10 | dependencies = [ 11 | "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 12 | ] 13 | 14 | [[package]] 15 | name = "byteorder" 16 | version = "1.3.1" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | 19 | [[package]] 20 | name = "cast" 21 | version = "0.2.2" 22 | source = "registry+https://github.com/rust-lang/crates.io-index" 23 | 24 | [[package]] 25 | name = "cortex-m" 26 | version = "0.5.8" 27 | source = "registry+https://github.com/rust-lang/crates.io-index" 28 | dependencies = [ 29 | "aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 30 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 31 | "volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 32 | ] 33 | 34 | [[package]] 35 | name = "cortex-m-rt" 36 | version = "0.6.7" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | dependencies = [ 39 | "cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 40 | "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 41 | ] 42 | 43 | [[package]] 44 | name = "cortex-m-rt-macros" 45 | version = "0.1.5" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | dependencies = [ 48 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 49 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 50 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 51 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 52 | ] 53 | 54 | [[package]] 55 | name = "cortex-m-rtfm" 56 | version = "0.4.1" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | dependencies = [ 59 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 60 | "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 61 | "cortex-m-rtfm-macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", 62 | "heapless 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 63 | "owned-singleton 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 64 | ] 65 | 66 | [[package]] 67 | name = "cortex-m-rtfm-macros" 68 | version = "0.4.1" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | dependencies = [ 71 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 72 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 73 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 74 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 75 | ] 76 | 77 | [[package]] 78 | name = "cortex-m-semihosting" 79 | version = "0.3.2" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | dependencies = [ 82 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 83 | ] 84 | 85 | [[package]] 86 | name = "dw1000" 87 | version = "0.1.0" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | dependencies = [ 90 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 91 | "ieee802154 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 92 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 93 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 94 | "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 95 | "ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 96 | ] 97 | 98 | [[package]] 99 | name = "dwm1001" 100 | version = "0.1.0" 101 | source = "git+https://github.com/braun-robotics/rust-dwm1001?rev=construct-by-parts#7574aee00133182d75809dd52b8d20b33cb0b581" 102 | dependencies = [ 103 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 104 | "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 105 | "cortex-m-semihosting 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 106 | "dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 107 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 108 | "nrf52832-hal 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 109 | ] 110 | 111 | [[package]] 112 | name = "embedded-hal" 113 | version = "0.2.2" 114 | source = "registry+https://github.com/rust-lang/crates.io-index" 115 | dependencies = [ 116 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 117 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 118 | ] 119 | 120 | [[package]] 121 | name = "encode_unicode" 122 | version = "0.3.5" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | 125 | [[package]] 126 | name = "generic-array" 127 | version = "0.11.1" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | dependencies = [ 130 | "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 131 | ] 132 | 133 | [[package]] 134 | name = "hash32" 135 | version = "0.1.0" 136 | source = "registry+https://github.com/rust-lang/crates.io-index" 137 | dependencies = [ 138 | "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 139 | ] 140 | 141 | [[package]] 142 | name = "hash32-derive" 143 | version = "0.1.0" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | dependencies = [ 146 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 147 | "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 148 | "syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)", 149 | ] 150 | 151 | [[package]] 152 | name = "heapless" 153 | version = "0.4.2" 154 | source = "registry+https://github.com/rust-lang/crates.io-index" 155 | dependencies = [ 156 | "generic-array 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", 157 | "hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 158 | ] 159 | 160 | [[package]] 161 | name = "ieee802154" 162 | version = "0.1.1" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | dependencies = [ 165 | "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 166 | "hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 167 | "hash32-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 168 | ] 169 | 170 | [[package]] 171 | name = "nb" 172 | version = "0.1.1" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | 175 | [[package]] 176 | name = "nrf52-hal-common" 177 | version = "0.7.0" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | dependencies = [ 180 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 181 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 182 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 183 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 184 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 185 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 186 | ] 187 | 188 | [[package]] 189 | name = "nrf52832-hal" 190 | version = "0.7.0" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | dependencies = [ 193 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 194 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 195 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 196 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 197 | "nrf52-hal-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 198 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 199 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 200 | ] 201 | 202 | [[package]] 203 | name = "nrf52832-pac" 204 | version = "0.6.0" 205 | source = "registry+https://github.com/rust-lang/crates.io-index" 206 | dependencies = [ 207 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 208 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 209 | "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 210 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 211 | ] 212 | 213 | [[package]] 214 | name = "owned-singleton" 215 | version = "0.1.0" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | dependencies = [ 218 | "owned-singleton-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 219 | "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 220 | ] 221 | 222 | [[package]] 223 | name = "owned-singleton-macros" 224 | version = "0.1.0" 225 | source = "registry+https://github.com/rust-lang/crates.io-index" 226 | dependencies = [ 227 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 228 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 229 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 230 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 231 | ] 232 | 233 | [[package]] 234 | name = "panic-ramdump" 235 | version = "0.1.0" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | dependencies = [ 238 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 239 | ] 240 | 241 | [[package]] 242 | name = "proc-macro2" 243 | version = "0.3.8" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | dependencies = [ 246 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 247 | ] 248 | 249 | [[package]] 250 | name = "proc-macro2" 251 | version = "0.4.27" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | dependencies = [ 254 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 255 | ] 256 | 257 | [[package]] 258 | name = "quote" 259 | version = "0.5.2" 260 | source = "registry+https://github.com/rust-lang/crates.io-index" 261 | dependencies = [ 262 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 263 | ] 264 | 265 | [[package]] 266 | name = "quote" 267 | version = "0.6.11" 268 | source = "registry+https://github.com/rust-lang/crates.io-index" 269 | dependencies = [ 270 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 271 | ] 272 | 273 | [[package]] 274 | name = "r0" 275 | version = "0.2.2" 276 | source = "registry+https://github.com/rust-lang/crates.io-index" 277 | 278 | [[package]] 279 | name = "rand" 280 | version = "0.5.6" 281 | source = "registry+https://github.com/rust-lang/crates.io-index" 282 | dependencies = [ 283 | "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 284 | ] 285 | 286 | [[package]] 287 | name = "rand_core" 288 | version = "0.3.1" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | dependencies = [ 291 | "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 292 | ] 293 | 294 | [[package]] 295 | name = "rand_core" 296 | version = "0.4.0" 297 | source = "registry+https://github.com/rust-lang/crates.io-index" 298 | 299 | [[package]] 300 | name = "rustc_version" 301 | version = "0.2.3" 302 | source = "registry+https://github.com/rust-lang/crates.io-index" 303 | dependencies = [ 304 | "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 305 | ] 306 | 307 | [[package]] 308 | name = "semver" 309 | version = "0.9.0" 310 | source = "registry+https://github.com/rust-lang/crates.io-index" 311 | dependencies = [ 312 | "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 313 | ] 314 | 315 | [[package]] 316 | name = "semver-parser" 317 | version = "0.7.0" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | 320 | [[package]] 321 | name = "sensor-node" 322 | version = "0.1.0" 323 | dependencies = [ 324 | "cortex-m-rtfm 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", 325 | "dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 326 | "dwm1001 0.1.0 (git+https://github.com/braun-robotics/rust-dwm1001?rev=construct-by-parts)", 327 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 328 | "heapless 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 329 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 330 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 331 | "panic-ramdump 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 332 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 333 | "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 334 | "ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 335 | ] 336 | 337 | [[package]] 338 | name = "serde" 339 | version = "1.0.85" 340 | source = "registry+https://github.com/rust-lang/crates.io-index" 341 | 342 | [[package]] 343 | name = "serde_derive" 344 | version = "1.0.85" 345 | source = "registry+https://github.com/rust-lang/crates.io-index" 346 | dependencies = [ 347 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 348 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 349 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 350 | ] 351 | 352 | [[package]] 353 | name = "ssmarshal" 354 | version = "1.0.0" 355 | source = "registry+https://github.com/rust-lang/crates.io-index" 356 | dependencies = [ 357 | "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 358 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 359 | ] 360 | 361 | [[package]] 362 | name = "stable_deref_trait" 363 | version = "1.1.1" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | 366 | [[package]] 367 | name = "syn" 368 | version = "0.13.11" 369 | source = "registry+https://github.com/rust-lang/crates.io-index" 370 | dependencies = [ 371 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 372 | "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 373 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 374 | ] 375 | 376 | [[package]] 377 | name = "syn" 378 | version = "0.15.26" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | dependencies = [ 381 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 382 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 383 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 384 | ] 385 | 386 | [[package]] 387 | name = "typenum" 388 | version = "1.10.0" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | 391 | [[package]] 392 | name = "unicode-xid" 393 | version = "0.1.0" 394 | source = "registry+https://github.com/rust-lang/crates.io-index" 395 | 396 | [[package]] 397 | name = "vcell" 398 | version = "0.1.0" 399 | source = "registry+https://github.com/rust-lang/crates.io-index" 400 | 401 | [[package]] 402 | name = "void" 403 | version = "1.0.2" 404 | source = "registry+https://github.com/rust-lang/crates.io-index" 405 | 406 | [[package]] 407 | name = "volatile-register" 408 | version = "0.2.0" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | dependencies = [ 411 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 412 | ] 413 | 414 | [metadata] 415 | "checksum aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d39da9b88ae1a81c03c9c082b8db83f1d0e93914126041962af61034ab44c4a5" 416 | "checksum bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3caf393d93b2d453e80638d0674597020cef3382ada454faacd43d1a55a735a" 417 | "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" 418 | "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" 419 | "checksum cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dab2164a0fc216781a47fc343347365112ae6917421d3fa4bac6faf0fbaaaec7" 420 | "checksum cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f69d2beca37acc3776c17201c9d1f8904fb9139fa3a4d2cf28c8436a07b21a88" 421 | "checksum cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d7ae692573e0acccb1579fef1abf5a5bf1d2f3f0149a22b16870ec9309aee25f" 422 | "checksum cortex-m-rtfm 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6b5c902cf9e63e346ac018f9462d30de7c502feab5351b3adca90cdd7771b74c" 423 | "checksum cortex-m-rtfm-macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40bb8b2e08acae1e0538bdc52168701c80bb8e8880c201507183190341261fea" 424 | "checksum cortex-m-semihosting 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1dc2abec1a772e8bb697cad17d5710f180043caf8939820f0f6ba4b7ae2a4b5" 425 | "checksum dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f77c3702f744259a3546f52a93b0818cb8ef35e8f2d5ae2fbc26ebdfcb79f31" 426 | "checksum dwm1001 0.1.0 (git+https://github.com/braun-robotics/rust-dwm1001?rev=construct-by-parts)" = "" 427 | "checksum embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9880e55238830314d41d88f1ac7a819d495799c3cc3bc392cc172bab26428c33" 428 | "checksum encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" 429 | "checksum generic-array 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8107dafa78c80c848b71b60133954b4a58609a3a1a5f9af037ecc7f67280f369" 430 | "checksum hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12d790435639c06a7b798af9e1e331ae245b7ef915b92f70a39b4cf8c00686af" 431 | "checksum hash32-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebc0efbd154a17cddc3616d83faef479c0076d871a2143c157b310cc7ca799a2" 432 | "checksum heapless 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "56b960caff1a46f1fb3c1eb05f0575ac21c6248364ebebde11b11116e099881c" 433 | "checksum ieee802154 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca800ffd69f7a11ecd8d13637603f5f227aac6e4c94e37cbecdaf63dfedbe4a" 434 | "checksum nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "69f380b5fe9fab8c0d7a6a99cda23e2cc0463bedb2cbc3aada0813b98496ecdc" 435 | "checksum nrf52-hal-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3de7d61b88c3f51a6d98207ae96a19556660d1f22e77b53f73eeff83cd4ff26e" 436 | "checksum nrf52832-hal 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "357ea63c48c9aa63d07e92262ceab0904697f61775a69a966ff0e33f259a3989" 437 | "checksum nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "979c2317388354d7dfc55c7b5098fd6becbb3ea588c7da627f2dcbcfd46a94bf" 438 | "checksum owned-singleton 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21aa378869c97c7db706a4c576cf0ce8258dc7e0e1ad25a97ee5aba1fd4eed83" 439 | "checksum owned-singleton-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d5c2ac071b95017bf70a5b607037fb0ef4abfa663fdf6cac8fbf36af9756ee3" 440 | "checksum panic-ramdump 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "699e5f8c3ae987deb02e8fea0099145f944b0d94b19efaa72d2d81484c908e4e" 441 | "checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7" 442 | "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" 443 | "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8" 444 | "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" 445 | "checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" 446 | "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" 447 | "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 448 | "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" 449 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 450 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 451 | "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 452 | "checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" 453 | "checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" 454 | "checksum ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" 455 | "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" 456 | "checksum syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b" 457 | "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" 458 | "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" 459 | "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" 460 | "checksum vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45c297f0afb6928cd08ab1ff9d95e99392595ea25ae1b5ecf822ff8764e57a0d" 461 | "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 462 | "checksum volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" 463 | -------------------------------------------------------------------------------- /pocs/sparkfun-7seg/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sparkfun-7seg" 3 | version = "0.1.0" 4 | authors = ["James Munns "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | panic-ramdump = "0.1.1" 9 | nb = "0.1.2" 10 | cortex-m-rtfm = "0.4.3" 11 | embedded-hal = "0.2.2" 12 | heapless = "0.4.3" 13 | postcard = "0.3.2" 14 | embedded-timeout-macros = "*" 15 | 16 | [dependencies.spark-ser7seg] 17 | path = "../../spark-ser7seg" 18 | 19 | [dependencies.dwm1001] 20 | version = "0.2.0" 21 | features = [ "dev", "rt" ] 22 | 23 | # Local workspace deps 24 | 25 | [dependencies.uarte-logger] 26 | path = "../../uarte-logger" 27 | 28 | [dependencies.utils] 29 | path = "../../utils" 30 | 31 | [dependencies.protocol] 32 | path = "../../protocol" 33 | -------------------------------------------------------------------------------- /pocs/sparkfun-7seg/debug.gdb: -------------------------------------------------------------------------------- 1 | target remote :2331 2 | mon reset 3 | load 4 | mon reset 5 | break main 6 | continue 7 | -------------------------------------------------------------------------------- /pocs/sparkfun-7seg/src/main.rs: -------------------------------------------------------------------------------- 1 | #![no_main] 2 | #![no_std] 3 | #![allow(unused_imports)] 4 | 5 | // Built in dependencies 6 | use core::fmt::Write; 7 | 8 | // Crates.io dependencies 9 | 10 | use dwm1001::{ 11 | self, 12 | nrf52832_hal::{ 13 | delay::Delay, 14 | prelude::*, 15 | timer::Timer, 16 | gpio::{Pin, Output, PushPull, Level, p0::P0_17}, 17 | rng::Rng, 18 | spim::{ 19 | Spim, 20 | Pins, 21 | MODE_0, 22 | Frequency as SpimFreq, 23 | }, 24 | nrf52832_pac::{ 25 | TIMER0, 26 | SPIM2, 27 | }, 28 | }, 29 | dw1000::{ 30 | mac::Address, 31 | mac::frame::{AddressMode, PanId, ShortAddress}, 32 | DW1000 as DW, 33 | Ready, 34 | }, 35 | new_dw1000, 36 | new_usb_uarte, 37 | UsbUarteConfig, 38 | DW_RST, 39 | block_timeout, 40 | embedded_hal::timer::CountDown, 41 | }; 42 | use heapless::{String, Vec, consts::*}; 43 | use nb::{ 44 | block, 45 | Error as NbError, 46 | }; 47 | use rtfm::app; 48 | use postcard::{from_bytes, to_vec}; 49 | 50 | // NOTE: Panic Provider 51 | use panic_ramdump as _; 52 | 53 | // Workspace dependencies 54 | use protocol::DemoMessage; 55 | use uarte_logger::Logger; 56 | use utils::delay; 57 | use embedded_timeout_macros::TimeoutError; 58 | 59 | use spark_ser7seg::{SevSegSpim, PunctuationFlags as Punc}; 60 | 61 | 62 | #[app(device = dwm1001::nrf52832_hal::nrf52832_pac)] 63 | const APP: () = { 64 | static mut LED_RED_1: Pin> = (); 65 | static mut TIMER: Timer = (); 66 | static mut LOGGER: Logger = (); 67 | static mut RANDOM: Rng = (); 68 | static mut DISPLAY: SevSegSpim, Pin>> = (); 69 | 70 | #[init] 71 | fn init() { 72 | let timer = device.TIMER0.constrain(); 73 | let pins = device.P0.split(); 74 | let uarte0 = new_usb_uarte( 75 | device.UARTE0, 76 | pins.p0_05, 77 | pins.p0_11, 78 | UsbUarteConfig::default(), 79 | ); 80 | 81 | // CS J1.29 P0.03 82 | // CLK J1.28 P0.04 83 | // MOSI J1.27 P0.06 84 | // MISO J1.26 P0.07 85 | 86 | let cs = pins.p0_03.into_push_pull_output(Level::High).degrade(); 87 | 88 | let spim = Spim::new( 89 | device.SPIM2, 90 | Pins { 91 | sck: pins.p0_04.into_push_pull_output(Level::Low).degrade(), 92 | mosi: Some(pins.p0_06.into_push_pull_output(Level::Low).degrade()), 93 | miso: Some(pins.p0_07.into_floating_input().degrade()), 94 | }, 95 | SpimFreq::K125, 96 | MODE_0, 97 | 0, 98 | ); 99 | 100 | let mut rng = device.RNG.constrain(); 101 | let mut delay = Delay::new(core.SYST); 102 | 103 | DISPLAY = SevSegSpim::new( 104 | spim, 105 | cs 106 | ); 107 | 108 | RANDOM = rng; 109 | LOGGER = Logger::new(uarte0); 110 | TIMER = timer; 111 | LED_RED_1 = pins.p0_14.degrade().into_push_pull_output(Level::High); 112 | } 113 | 114 | #[idle(resources = [TIMER, LED_RED_1, LOGGER, RANDOM, DISPLAY])] 115 | fn idle() -> ! { 116 | let mut ctr = 0; 117 | 118 | resources.DISPLAY.clear().unwrap(); 119 | 120 | // pub struct PunctuationFlags: u8 { 121 | // const DOT_BETWEEN_1_AND_2 = 0b0000_0001; 122 | // const DOT_BETWEEN_2_AND_3 = 0b0000_0010; 123 | // const DOT_BETWEEN_3_AND_4 = 0b0000_0100; 124 | // const DOT_RIGHT_OF_4 = 0b0000_1000; 125 | // const DOTS_COLON = 0b0001_0000; 126 | // const APOSTROPHE_BETWEEN_3_AND_4 = 0b0010_0000; 127 | // } 128 | 129 | resources.DISPLAY.write_punctuation( 130 | Punc::DOT_BETWEEN_1_AND_2 131 | ).unwrap(); 132 | 133 | resources.TIMER.start(1_000_000u32); 134 | while resources.TIMER.wait().is_err() {} 135 | 136 | resources.DISPLAY.write_punctuation( 137 | Punc::DOT_BETWEEN_2_AND_3 138 | ).unwrap(); 139 | 140 | resources.TIMER.start(1_000_000u32); 141 | while resources.TIMER.wait().is_err() {} 142 | 143 | resources.DISPLAY.write_punctuation( 144 | Punc::DOT_BETWEEN_3_AND_4 145 | ).unwrap(); 146 | 147 | resources.TIMER.start(1_000_000u32); 148 | while resources.TIMER.wait().is_err() {} 149 | 150 | resources.DISPLAY.write_punctuation( 151 | Punc::DOT_RIGHT_OF_4 152 | ).unwrap(); 153 | 154 | resources.TIMER.start(1_000_000u32); 155 | while resources.TIMER.wait().is_err() {} 156 | 157 | resources.DISPLAY.write_punctuation( 158 | Punc::DOTS_COLON 159 | ).unwrap(); 160 | 161 | resources.TIMER.start(1_000_000u32); 162 | while resources.TIMER.wait().is_err() {} 163 | 164 | resources.DISPLAY.write_punctuation( 165 | Punc::APOSTROPHE_BETWEEN_3_AND_4 166 | ).unwrap(); 167 | 168 | resources.TIMER.start(1_000_000u32); 169 | while resources.TIMER.wait().is_err() {} 170 | 171 | resources.DISPLAY.write_punctuation( 172 | Punc::empty() 173 | ).unwrap(); 174 | 175 | loop { 176 | resources.TIMER.start(8_000u32); 177 | while resources.TIMER.wait().is_err() {} 178 | (*resources.LED_RED_1).set_low(); 179 | 180 | resources.DISPLAY.set_num( 181 | ctr, 182 | ).unwrap(); 183 | 184 | ctr += 1; 185 | 186 | if ctr >= 10000 { 187 | ctr = 0; 188 | } 189 | 190 | resources.TIMER.start(2_000u32); 191 | while resources.TIMER.wait().is_err() {} 192 | (*resources.LED_RED_1).set_high(); 193 | } 194 | } 195 | }; 196 | 197 | -------------------------------------------------------------------------------- /protocol/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "protocol" 3 | version = "0.1.0" 4 | authors = ["James Munns "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | 9 | [dependencies.serde] 10 | version = "1.0" 11 | default-features = false 12 | features = ["derive"] 13 | -------------------------------------------------------------------------------- /protocol/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | use serde::{Deserialize, Serialize}; 4 | 5 | #[derive(Debug, Deserialize, Serialize)] 6 | pub struct DemoMessage<'a> { 7 | pub small: u8, 8 | pub medium: u32, 9 | pub large: u64, 10 | pub text_bytes: &'a str, 11 | } 12 | -------------------------------------------------------------------------------- /sensor-node/Cargo.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "aligned" 3 | version = "0.2.0" 4 | source = "registry+https://github.com/rust-lang/crates.io-index" 5 | 6 | [[package]] 7 | name = "bare-metal" 8 | version = "0.2.4" 9 | source = "registry+https://github.com/rust-lang/crates.io-index" 10 | dependencies = [ 11 | "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 12 | ] 13 | 14 | [[package]] 15 | name = "byteorder" 16 | version = "1.3.1" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | 19 | [[package]] 20 | name = "cast" 21 | version = "0.2.2" 22 | source = "registry+https://github.com/rust-lang/crates.io-index" 23 | 24 | [[package]] 25 | name = "cortex-m" 26 | version = "0.5.8" 27 | source = "registry+https://github.com/rust-lang/crates.io-index" 28 | dependencies = [ 29 | "aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 30 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 31 | "volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 32 | ] 33 | 34 | [[package]] 35 | name = "cortex-m-rt" 36 | version = "0.6.7" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | dependencies = [ 39 | "cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 40 | "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 41 | ] 42 | 43 | [[package]] 44 | name = "cortex-m-rt-macros" 45 | version = "0.1.5" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | dependencies = [ 48 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 49 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 50 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 51 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 52 | ] 53 | 54 | [[package]] 55 | name = "cortex-m-rtfm" 56 | version = "0.4.1" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | dependencies = [ 59 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 60 | "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 61 | "cortex-m-rtfm-macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", 62 | "heapless 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 63 | "owned-singleton 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 64 | ] 65 | 66 | [[package]] 67 | name = "cortex-m-rtfm-macros" 68 | version = "0.4.1" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | dependencies = [ 71 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 72 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 73 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 74 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 75 | ] 76 | 77 | [[package]] 78 | name = "cortex-m-semihosting" 79 | version = "0.3.2" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | dependencies = [ 82 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 83 | ] 84 | 85 | [[package]] 86 | name = "dw1000" 87 | version = "0.1.0" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | dependencies = [ 90 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 91 | "ieee802154 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 92 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 93 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 94 | "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 95 | "ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 96 | ] 97 | 98 | [[package]] 99 | name = "dwm1001" 100 | version = "0.1.0" 101 | source = "git+https://github.com/braun-robotics/rust-dwm1001?rev=construct-by-parts#7574aee00133182d75809dd52b8d20b33cb0b581" 102 | dependencies = [ 103 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 104 | "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 105 | "cortex-m-semihosting 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 106 | "dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 107 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 108 | "nrf52832-hal 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 109 | ] 110 | 111 | [[package]] 112 | name = "embedded-hal" 113 | version = "0.2.2" 114 | source = "registry+https://github.com/rust-lang/crates.io-index" 115 | dependencies = [ 116 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 117 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 118 | ] 119 | 120 | [[package]] 121 | name = "encode_unicode" 122 | version = "0.3.5" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | 125 | [[package]] 126 | name = "generic-array" 127 | version = "0.11.1" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | dependencies = [ 130 | "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 131 | ] 132 | 133 | [[package]] 134 | name = "hash32" 135 | version = "0.1.0" 136 | source = "registry+https://github.com/rust-lang/crates.io-index" 137 | dependencies = [ 138 | "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 139 | ] 140 | 141 | [[package]] 142 | name = "hash32-derive" 143 | version = "0.1.0" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | dependencies = [ 146 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 147 | "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 148 | "syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)", 149 | ] 150 | 151 | [[package]] 152 | name = "heapless" 153 | version = "0.4.2" 154 | source = "registry+https://github.com/rust-lang/crates.io-index" 155 | dependencies = [ 156 | "generic-array 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", 157 | "hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 158 | ] 159 | 160 | [[package]] 161 | name = "ieee802154" 162 | version = "0.1.1" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | dependencies = [ 165 | "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 166 | "hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 167 | "hash32-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 168 | ] 169 | 170 | [[package]] 171 | name = "nb" 172 | version = "0.1.1" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | 175 | [[package]] 176 | name = "nrf52-hal-common" 177 | version = "0.7.0" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | dependencies = [ 180 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 181 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 182 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 183 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 184 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 185 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 186 | ] 187 | 188 | [[package]] 189 | name = "nrf52832-hal" 190 | version = "0.7.0" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | dependencies = [ 193 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 194 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 195 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 196 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 197 | "nrf52-hal-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 198 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 199 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 200 | ] 201 | 202 | [[package]] 203 | name = "nrf52832-pac" 204 | version = "0.6.0" 205 | source = "registry+https://github.com/rust-lang/crates.io-index" 206 | dependencies = [ 207 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 208 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 209 | "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 210 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 211 | ] 212 | 213 | [[package]] 214 | name = "owned-singleton" 215 | version = "0.1.0" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | dependencies = [ 218 | "owned-singleton-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 219 | "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 220 | ] 221 | 222 | [[package]] 223 | name = "owned-singleton-macros" 224 | version = "0.1.0" 225 | source = "registry+https://github.com/rust-lang/crates.io-index" 226 | dependencies = [ 227 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 228 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 229 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 230 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 231 | ] 232 | 233 | [[package]] 234 | name = "panic-ramdump" 235 | version = "0.1.0" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | dependencies = [ 238 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 239 | ] 240 | 241 | [[package]] 242 | name = "proc-macro2" 243 | version = "0.3.8" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | dependencies = [ 246 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 247 | ] 248 | 249 | [[package]] 250 | name = "proc-macro2" 251 | version = "0.4.27" 252 | source = "registry+https://github.com/rust-lang/crates.io-index" 253 | dependencies = [ 254 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 255 | ] 256 | 257 | [[package]] 258 | name = "quote" 259 | version = "0.5.2" 260 | source = "registry+https://github.com/rust-lang/crates.io-index" 261 | dependencies = [ 262 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 263 | ] 264 | 265 | [[package]] 266 | name = "quote" 267 | version = "0.6.11" 268 | source = "registry+https://github.com/rust-lang/crates.io-index" 269 | dependencies = [ 270 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 271 | ] 272 | 273 | [[package]] 274 | name = "r0" 275 | version = "0.2.2" 276 | source = "registry+https://github.com/rust-lang/crates.io-index" 277 | 278 | [[package]] 279 | name = "rand" 280 | version = "0.5.6" 281 | source = "registry+https://github.com/rust-lang/crates.io-index" 282 | dependencies = [ 283 | "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 284 | ] 285 | 286 | [[package]] 287 | name = "rand_core" 288 | version = "0.3.1" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | dependencies = [ 291 | "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 292 | ] 293 | 294 | [[package]] 295 | name = "rand_core" 296 | version = "0.4.0" 297 | source = "registry+https://github.com/rust-lang/crates.io-index" 298 | 299 | [[package]] 300 | name = "rustc_version" 301 | version = "0.2.3" 302 | source = "registry+https://github.com/rust-lang/crates.io-index" 303 | dependencies = [ 304 | "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 305 | ] 306 | 307 | [[package]] 308 | name = "semver" 309 | version = "0.9.0" 310 | source = "registry+https://github.com/rust-lang/crates.io-index" 311 | dependencies = [ 312 | "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 313 | ] 314 | 315 | [[package]] 316 | name = "semver-parser" 317 | version = "0.7.0" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | 320 | [[package]] 321 | name = "sensor-node" 322 | version = "0.1.0" 323 | dependencies = [ 324 | "cortex-m-rtfm 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", 325 | "dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 326 | "dwm1001 0.1.0 (git+https://github.com/braun-robotics/rust-dwm1001?rev=construct-by-parts)", 327 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 328 | "heapless 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 329 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 330 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 331 | "panic-ramdump 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 332 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 333 | "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 334 | "ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 335 | ] 336 | 337 | [[package]] 338 | name = "serde" 339 | version = "1.0.85" 340 | source = "registry+https://github.com/rust-lang/crates.io-index" 341 | 342 | [[package]] 343 | name = "serde_derive" 344 | version = "1.0.85" 345 | source = "registry+https://github.com/rust-lang/crates.io-index" 346 | dependencies = [ 347 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 348 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 349 | "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", 350 | ] 351 | 352 | [[package]] 353 | name = "ssmarshal" 354 | version = "1.0.0" 355 | source = "registry+https://github.com/rust-lang/crates.io-index" 356 | dependencies = [ 357 | "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 358 | "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", 359 | ] 360 | 361 | [[package]] 362 | name = "stable_deref_trait" 363 | version = "1.1.1" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | 366 | [[package]] 367 | name = "syn" 368 | version = "0.13.11" 369 | source = "registry+https://github.com/rust-lang/crates.io-index" 370 | dependencies = [ 371 | "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 372 | "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 373 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 374 | ] 375 | 376 | [[package]] 377 | name = "syn" 378 | version = "0.15.26" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | dependencies = [ 381 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 382 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 383 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 384 | ] 385 | 386 | [[package]] 387 | name = "typenum" 388 | version = "1.10.0" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | 391 | [[package]] 392 | name = "unicode-xid" 393 | version = "0.1.0" 394 | source = "registry+https://github.com/rust-lang/crates.io-index" 395 | 396 | [[package]] 397 | name = "vcell" 398 | version = "0.1.0" 399 | source = "registry+https://github.com/rust-lang/crates.io-index" 400 | 401 | [[package]] 402 | name = "void" 403 | version = "1.0.2" 404 | source = "registry+https://github.com/rust-lang/crates.io-index" 405 | 406 | [[package]] 407 | name = "volatile-register" 408 | version = "0.2.0" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | dependencies = [ 411 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 412 | ] 413 | 414 | [metadata] 415 | "checksum aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d39da9b88ae1a81c03c9c082b8db83f1d0e93914126041962af61034ab44c4a5" 416 | "checksum bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3caf393d93b2d453e80638d0674597020cef3382ada454faacd43d1a55a735a" 417 | "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" 418 | "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" 419 | "checksum cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dab2164a0fc216781a47fc343347365112ae6917421d3fa4bac6faf0fbaaaec7" 420 | "checksum cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f69d2beca37acc3776c17201c9d1f8904fb9139fa3a4d2cf28c8436a07b21a88" 421 | "checksum cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d7ae692573e0acccb1579fef1abf5a5bf1d2f3f0149a22b16870ec9309aee25f" 422 | "checksum cortex-m-rtfm 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6b5c902cf9e63e346ac018f9462d30de7c502feab5351b3adca90cdd7771b74c" 423 | "checksum cortex-m-rtfm-macros 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40bb8b2e08acae1e0538bdc52168701c80bb8e8880c201507183190341261fea" 424 | "checksum cortex-m-semihosting 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d1dc2abec1a772e8bb697cad17d5710f180043caf8939820f0f6ba4b7ae2a4b5" 425 | "checksum dw1000 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f77c3702f744259a3546f52a93b0818cb8ef35e8f2d5ae2fbc26ebdfcb79f31" 426 | "checksum dwm1001 0.1.0 (git+https://github.com/braun-robotics/rust-dwm1001?rev=construct-by-parts)" = "" 427 | "checksum embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9880e55238830314d41d88f1ac7a819d495799c3cc3bc392cc172bab26428c33" 428 | "checksum encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" 429 | "checksum generic-array 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8107dafa78c80c848b71b60133954b4a58609a3a1a5f9af037ecc7f67280f369" 430 | "checksum hash32 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12d790435639c06a7b798af9e1e331ae245b7ef915b92f70a39b4cf8c00686af" 431 | "checksum hash32-derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebc0efbd154a17cddc3616d83faef479c0076d871a2143c157b310cc7ca799a2" 432 | "checksum heapless 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "56b960caff1a46f1fb3c1eb05f0575ac21c6248364ebebde11b11116e099881c" 433 | "checksum ieee802154 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca800ffd69f7a11ecd8d13637603f5f227aac6e4c94e37cbecdaf63dfedbe4a" 434 | "checksum nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "69f380b5fe9fab8c0d7a6a99cda23e2cc0463bedb2cbc3aada0813b98496ecdc" 435 | "checksum nrf52-hal-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3de7d61b88c3f51a6d98207ae96a19556660d1f22e77b53f73eeff83cd4ff26e" 436 | "checksum nrf52832-hal 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "357ea63c48c9aa63d07e92262ceab0904697f61775a69a966ff0e33f259a3989" 437 | "checksum nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "979c2317388354d7dfc55c7b5098fd6becbb3ea588c7da627f2dcbcfd46a94bf" 438 | "checksum owned-singleton 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21aa378869c97c7db706a4c576cf0ce8258dc7e0e1ad25a97ee5aba1fd4eed83" 439 | "checksum owned-singleton-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d5c2ac071b95017bf70a5b607037fb0ef4abfa663fdf6cac8fbf36af9756ee3" 440 | "checksum panic-ramdump 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "699e5f8c3ae987deb02e8fea0099145f944b0d94b19efaa72d2d81484c908e4e" 441 | "checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7" 442 | "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" 443 | "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8" 444 | "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" 445 | "checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" 446 | "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" 447 | "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 448 | "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" 449 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 450 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 451 | "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 452 | "checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" 453 | "checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" 454 | "checksum ssmarshal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f3e6ad23b128192ed337dfa4f1b8099ced0c2bf30d61e551b65fda5916dbb850" 455 | "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" 456 | "checksum syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b" 457 | "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" 458 | "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" 459 | "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" 460 | "checksum vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45c297f0afb6928cd08ab1ff9d95e99392595ea25ae1b5ecf822ff8764e57a0d" 461 | "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 462 | "checksum volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" 463 | -------------------------------------------------------------------------------- /sensor-node/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sensor-node" 3 | version = "0.1.0" 4 | authors = ["James Munns "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | panic-ramdump = "0.1.1" 9 | nb = "0.1.2" 10 | cortex-m-rtfm = "0.4.3" 11 | embedded-hal = "0.2.2" 12 | heapless = "0.4.3" 13 | postcard = "0.3.2" 14 | embedded-timeout-macros = "*" 15 | 16 | [dependencies.dwm1001] 17 | version = "0.2.0" 18 | features = [ "dev", "rt" ] 19 | 20 | # Local workspace deps 21 | 22 | [dependencies.uarte-logger] 23 | path = "../uarte-logger" 24 | 25 | [dependencies.utils] 26 | path = "../utils" 27 | 28 | [dependencies.protocol] 29 | path = "../protocol" 30 | -------------------------------------------------------------------------------- /sensor-node/debug.gdb: -------------------------------------------------------------------------------- 1 | target remote :2331 2 | mon reset 3 | load 4 | mon reset 5 | break main 6 | continue 7 | -------------------------------------------------------------------------------- /sensor-node/src/main.rs: -------------------------------------------------------------------------------- 1 | #![no_main] 2 | #![no_std] 3 | 4 | // Built in dependencies 5 | use core::fmt::Write; 6 | 7 | // Crates.io dependencies 8 | use dwm1001::{ 9 | self, 10 | nrf52832_hal::{ 11 | delay::Delay, 12 | prelude::*, 13 | timer::Timer, 14 | gpio::{Pin, Output, PushPull, Level, p0::P0_17}, 15 | rng::Rng, 16 | spim::Spim, 17 | nrf52832_pac::{ 18 | TIMER0, 19 | SPIM2, 20 | }, 21 | }, 22 | dw1000::{ 23 | mac::Address, 24 | mac::frame::{AddressMode, PanId, ShortAddress}, 25 | DW1000 as DW, 26 | Ready, 27 | }, 28 | new_dw1000, 29 | new_usb_uarte, 30 | UsbUarteConfig, 31 | DW_RST, 32 | block_timeout, 33 | embedded_hal::timer::CountDown, 34 | }; 35 | use heapless::{String, Vec, consts::*}; 36 | use nb::{ 37 | block, 38 | Error as NbError, 39 | }; 40 | use rtfm::app; 41 | use postcard::{from_bytes, to_vec}; 42 | 43 | // NOTE: Panic Provider 44 | use panic_ramdump as _; 45 | 46 | // Workspace dependencies 47 | use protocol::DemoMessage; 48 | use uarte_logger::Logger; 49 | use utils::delay; 50 | use embedded_timeout_macros::TimeoutError; 51 | 52 | 53 | const NOMINAL_WAIT_US: u32 = 400_000; 54 | const MAX_WAIT_JITTER_US: u32 = 200_000; 55 | 56 | 57 | #[app(device = dwm1001::nrf52832_hal::nrf52832_pac)] 58 | const APP: () = { 59 | static mut LED_RED_1: Pin> = (); 60 | static mut TIMER: Timer = (); 61 | static mut LOGGER: Logger = (); 62 | static mut DW1000: DW< 63 | Spim, 64 | P0_17>, 65 | Ready, 66 | > = (); 67 | static mut DW_RST_PIN: DW_RST = (); 68 | static mut RANDOM: Rng = (); 69 | 70 | #[init] 71 | fn init() { 72 | let timer = device.TIMER0.constrain(); 73 | let pins = device.P0.split(); 74 | let uarte0 = new_usb_uarte( 75 | device.UARTE0, 76 | pins.p0_05, 77 | pins.p0_11, 78 | UsbUarteConfig::default(), 79 | ); 80 | 81 | let mut rng = device.RNG.constrain(); 82 | 83 | let dw1000 = new_dw1000( 84 | device.SPIM2, 85 | pins.p0_16, 86 | pins.p0_20, 87 | pins.p0_18, 88 | pins.p0_17, 89 | None, 90 | ); 91 | 92 | let mut rst_pin = DW_RST::new(pins.p0_24.into_floating_input()); 93 | let mut delay = Delay::new(core.SYST); 94 | 95 | rst_pin.reset_dw1000(&mut delay); 96 | 97 | let mut dw1000 = dw1000.init().unwrap(); 98 | 99 | let pan_id = PanId::decode(&(0x0386u16.to_le_bytes())).unwrap().0; 100 | let saddr = ShortAddress::decode(&rng.random_u16().to_le_bytes()).unwrap().0; 101 | 102 | let addr = Address::Short( 103 | pan_id, 104 | saddr, 105 | ); 106 | 107 | loop { 108 | if dw1000.set_address( 109 | pan_id, 110 | saddr, 111 | ).is_err() { 112 | continue; 113 | } 114 | 115 | if let Ok(raddr) = dw1000.get_address() { 116 | if addr == raddr { 117 | break; 118 | } 119 | } 120 | } 121 | 122 | RANDOM = rng; 123 | DW_RST_PIN = rst_pin; 124 | DW1000 = dw1000; 125 | LOGGER = Logger::new(uarte0); 126 | TIMER = timer; 127 | LED_RED_1 = pins.p0_14.degrade().into_push_pull_output(Level::High); 128 | } 129 | 130 | #[idle(resources = [TIMER, LED_RED_1, LOGGER, RANDOM, DW1000])] 131 | fn idle() -> ! { 132 | let mut scratch = [0u8; 4096]; 133 | loop { 134 | let jitter = resources.RANDOM.random_u32() % MAX_WAIT_JITTER_US; 135 | resources.TIMER.start(NOMINAL_WAIT_US + jitter); 136 | let message = rand_msg(&mut resources.RANDOM); 137 | let serd: Vec = to_vec(&message).expect("ser fail"); 138 | 139 | let mut tx_fut = resources.DW1000.send( 140 | &serd, 141 | Address::broadcast(&AddressMode::Short), 142 | None 143 | ).expect("tx fail"); 144 | 145 | match block_timeout!(&mut *resources.TIMER, tx_fut.wait()) { 146 | Ok(_) => { 147 | resources.LOGGER.log("Sent hello").expect("hello fail"); 148 | }, 149 | _ => continue, 150 | }; 151 | 152 | 153 | 154 | let mut rx_fut = resources.DW1000.receive().expect("rx fut fail"); 155 | 156 | match block_timeout!(&mut *resources.TIMER, rx_fut.wait(&mut scratch)) { 157 | Ok(msg) => { 158 | match from_bytes::(msg.frame.payload) { 159 | Ok(val) => { 160 | let mut out: String = String::new(); 161 | write!(&mut out, "got message! \r\n").unwrap(); 162 | write!(&mut out, "small: {:016X}\r\n", val.small).unwrap(); 163 | write!(&mut out, "med: {:016X}\r\n", val.medium).unwrap(); 164 | write!(&mut out, "large {:016X}\r\n", val.large).unwrap(); 165 | write!(&mut out, "text: {}\r\n", &val.text_bytes).unwrap(); 166 | resources.LOGGER.log(&out).unwrap(); 167 | } 168 | _ => { 169 | resources.LOGGER.error("failed to deser").unwrap(); 170 | } 171 | } 172 | 173 | // Drain out the rest of the time 174 | while resources.TIMER.wait().is_err() {} 175 | } 176 | Err(TimeoutError::Timeout) => { 177 | resources.LOGGER.log("No Packet!").expect("no log fail"); 178 | } 179 | Err(TimeoutError::Other(error)) => { 180 | let mut out: String = String::new(); 181 | write!(&mut out, "rx fail: {:?}", error).unwrap(); 182 | resources.LOGGER.error(out.as_str()).unwrap(); 183 | } 184 | }; 185 | 186 | resources.DW1000.force_idle().expect("idle fail"); 187 | } 188 | } 189 | }; 190 | 191 | 192 | pub fn rand_msg(rng: &mut Rng) -> DemoMessage<'static> { 193 | let start = (rng.random_u32() % ((MEME.len() - 64) as u32)) as usize; 194 | let len = ((rng.random_u32() % 63) + 1) as usize; 195 | 196 | DemoMessage { 197 | small: rng.random_u8(), 198 | medium: rng.random_u32(), 199 | large: rng.random_u64(), 200 | text_bytes: &MEME[start..(start+len)], 201 | } 202 | } 203 | 204 | 205 | pub const MEME: &str = "Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. It's not a story the Jedi would tell you. It's a Sith legend. Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life... He had such a knowledge of the dark side that he could even keep the ones he cared about from dying. The dark side of the Force is a pathway to many abilities some consider to be unnatural. He became so powerful... the only thing he was afraid of was losing his power, which eventually, of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. Ironic. He could save others from death, but not himself."; 206 | -------------------------------------------------------------------------------- /spark-ser7seg/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "spark-ser7seg" 3 | version = "0.1.0" 4 | authors = ["James Munns "] 5 | edition = "2018" 6 | 7 | license = "MIT OR Apache-2.0" 8 | repository = "https://github.com/ferrous-systems/internet-of-streams" 9 | documentation = "https://docs.rs/sparkfun-7seg" 10 | description = "An embedded-hal driver for the SparkFun Serial 7 Segment Display" 11 | 12 | categories = [ 13 | "embedded", 14 | "hardware-support", 15 | "no-std", 16 | ] 17 | 18 | keywords = [ 19 | "embedded-hal-driver", 20 | ] 21 | 22 | [dependencies] 23 | bitflags = "1.0" 24 | embedded-hal = "0.2" 25 | -------------------------------------------------------------------------------- /spark-ser7seg/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Driver for the [SparkFun Serial 7 Segment Display](https://github.com/sparkfun/Serial7SegmentDisplay/wiki/Serial-7-Segment-Display-Datasheet) 2 | //! 3 | //! This is compatible with `embedded-hal`. 4 | //! 5 | //! Right now, only the SPI interface is supported. In the future, support will be 6 | //! added for I2C/TWI and UART interfaces 7 | 8 | #![no_std] 9 | 10 | use embedded_hal::blocking::spi::Write; 11 | use embedded_hal::digital::OutputPin; 12 | use bitflags::bitflags; 13 | 14 | bitflags! { 15 | /// A bit packed structure representing days of the week 16 | pub struct PunctuationFlags: u8 { 17 | const DOT_BETWEEN_1_AND_2 = 0b0000_0001; 18 | const DOT_BETWEEN_2_AND_3 = 0b0000_0010; 19 | const DOT_BETWEEN_3_AND_4 = 0b0000_0100; 20 | const DOT_RIGHT_OF_4 = 0b0000_1000; 21 | const DOTS_COLON = 0b0001_0000; 22 | const APOSTROPHE_BETWEEN_3_AND_4 = 0b0010_0000; 23 | } 24 | } 25 | 26 | mod command { 27 | #![allow(dead_code)] 28 | 29 | pub(crate) const CLEAR_DISPLAY: u8 = 0x76; 30 | 31 | pub(crate) const DECIMAL_CTL: u8 = 0x77; 32 | pub(crate) const CURSOR_CTL: u8 = 0x79; 33 | pub(crate) const BRIGHTNESS_CTL: u8 = 0x7A; 34 | 35 | pub(crate) const DIGIT_1_CTL: u8 = 0x7B; 36 | pub(crate) const DIGIT_2_CTL: u8 = 0x7C; 37 | pub(crate) const DIGIT_3_CTL: u8 = 0x7D; 38 | pub(crate) const DIGIT_4_CTL: u8 = 0x7E; 39 | 40 | pub(crate) const BAUD_RATE_CFG: u8 = 0x7F; 41 | pub(crate) const I2C_ADDR_CFG: u8 = 0x80; 42 | 43 | pub(crate) const FACTORY_RESET: u8 = 0x81; 44 | } 45 | 46 | #[derive(Debug, Eq, PartialEq)] 47 | pub enum Error { 48 | SpimError(T), 49 | CursorOutOfRange, 50 | DigitOutOfRange, 51 | } 52 | 53 | pub struct SevSegSpim { 54 | spim: SPIM, 55 | csn: CS, 56 | } 57 | 58 | impl SevSegSpim 59 | where 60 | SPIM: Write, 61 | CS: OutputPin, 62 | { 63 | /// Create a new SparkFun Serial Seven Segment display using a SPI (Master) 64 | /// port. The SPI port has a maximum frequency of 250kHz, and must be in Mode 0. 65 | pub fn new(spim: SPIM, csn: CS) -> Self { 66 | Self { 67 | spim, 68 | csn, 69 | } 70 | } 71 | 72 | /// Set the digit cursor to a particular location 73 | /// `col` may be 0..=3, from left to right. 74 | pub fn set_cursor(&mut self, col: u8) -> Result<(), Error> { 75 | if col >= 4 { 76 | return Err(Error::CursorOutOfRange); 77 | } 78 | 79 | self.send(&[ 80 | command::CURSOR_CTL, 81 | col, 82 | ]) 83 | } 84 | 85 | /// Completely clear the display 86 | pub fn clear(&mut self) -> Result<(), Error> { 87 | self.send(&[command::CLEAR_DISPLAY]) 88 | } 89 | 90 | /// Write a digit to the curent cursor position. This also 91 | /// increments the cursor position 92 | pub fn write_digit(&mut self, digit: u8) -> Result<(), Error> { 93 | if digit > 0x0F { 94 | return Err(Error::DigitOutOfRange); 95 | } 96 | 97 | self.send(&[digit]) 98 | } 99 | 100 | /// Write the requested punctuation to the display. This does not take 101 | /// the current state into account, so any unset flags in `punct_flags` 102 | /// will turn the corresponding LEDs off. 103 | pub fn write_punctuation(&mut self, punct_flags: PunctuationFlags) -> Result<(), Error> { 104 | self.send(&[ 105 | command::DECIMAL_CTL, 106 | punct_flags.bits() 107 | ]) 108 | } 109 | 110 | /// Write the requested digits to the display, starting at the current 111 | /// cursor position. Each digit must be in the range 0x0..=0xF, and up 112 | /// to 4 digits may be updated at once. The cursor is incremented after 113 | /// each digit 114 | pub fn write_digits(&mut self, digits: &[u8]) -> Result<(), Error> { 115 | // Too many digits? 116 | if digits.len() > 4 { 117 | return Err(Error::CursorOutOfRange); 118 | } 119 | 120 | // Any digit too big? 121 | for d in digits { 122 | if *d > 0x0F { 123 | return Err(Error::DigitOutOfRange); 124 | } 125 | } 126 | 127 | self.send(digits) 128 | } 129 | 130 | /// Write the number to the display. The number will be left-filled 131 | /// with zeroes if necessary. After this function, the cursor 132 | /// will be at position 0. 133 | pub fn set_num(&mut self, num: u16) -> Result<(), Error> { 134 | if num > 9999 { 135 | return Err(Error::DigitOutOfRange); 136 | } 137 | 138 | self.set_cursor(0)?; 139 | 140 | let data: [u8; 4] = [ 141 | (num / 1000) as u8, 142 | ((num % 1000) / 100) as u8, 143 | ((num % 100) / 10) as u8, 144 | (num % 10) as u8, 145 | ]; 146 | 147 | self.send(&data) 148 | } 149 | 150 | fn send(&mut self, data: &[u8]) -> Result<(), Error> { 151 | self.csn.set_low(); 152 | 153 | let ret = self.spim 154 | .write(&data) 155 | .map_err(|e| Error::SpimError(e)) 156 | .map(|_| ()); 157 | 158 | self.csn.set_high(); 159 | 160 | ret 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /uarte-logger/Cargo.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "aligned" 3 | version = "0.2.0" 4 | source = "registry+https://github.com/rust-lang/crates.io-index" 5 | 6 | [[package]] 7 | name = "bare-metal" 8 | version = "0.2.4" 9 | source = "registry+https://github.com/rust-lang/crates.io-index" 10 | dependencies = [ 11 | "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 12 | ] 13 | 14 | [[package]] 15 | name = "cast" 16 | version = "0.2.2" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | 19 | [[package]] 20 | name = "cortex-m" 21 | version = "0.5.8" 22 | source = "registry+https://github.com/rust-lang/crates.io-index" 23 | dependencies = [ 24 | "aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 25 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 26 | "volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 27 | ] 28 | 29 | [[package]] 30 | name = "cortex-m-rt" 31 | version = "0.6.7" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | dependencies = [ 34 | "cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 35 | "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 36 | ] 37 | 38 | [[package]] 39 | name = "cortex-m-rt-macros" 40 | version = "0.1.5" 41 | source = "registry+https://github.com/rust-lang/crates.io-index" 42 | dependencies = [ 43 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 44 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 45 | "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 46 | "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", 47 | ] 48 | 49 | [[package]] 50 | name = "embedded-hal" 51 | version = "0.2.2" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | dependencies = [ 54 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 55 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 56 | ] 57 | 58 | [[package]] 59 | name = "nb" 60 | version = "0.1.1" 61 | source = "registry+https://github.com/rust-lang/crates.io-index" 62 | 63 | [[package]] 64 | name = "nrf52-hal-common" 65 | version = "0.7.0" 66 | source = "registry+https://github.com/rust-lang/crates.io-index" 67 | dependencies = [ 68 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 69 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 70 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 71 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 72 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 73 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 74 | ] 75 | 76 | [[package]] 77 | name = "nrf52832-hal" 78 | version = "0.7.0" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | dependencies = [ 81 | "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 82 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 83 | "embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 84 | "nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 85 | "nrf52-hal-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 86 | "nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", 87 | "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 88 | ] 89 | 90 | [[package]] 91 | name = "nrf52832-pac" 92 | version = "0.6.0" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | dependencies = [ 95 | "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 96 | "cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", 97 | "cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 98 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 99 | ] 100 | 101 | [[package]] 102 | name = "proc-macro2" 103 | version = "0.4.27" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | dependencies = [ 106 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 107 | ] 108 | 109 | [[package]] 110 | name = "quote" 111 | version = "0.6.11" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | dependencies = [ 114 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 115 | ] 116 | 117 | [[package]] 118 | name = "r0" 119 | version = "0.2.2" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | 122 | [[package]] 123 | name = "rand" 124 | version = "0.5.6" 125 | source = "registry+https://github.com/rust-lang/crates.io-index" 126 | dependencies = [ 127 | "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 128 | ] 129 | 130 | [[package]] 131 | name = "rand_core" 132 | version = "0.3.1" 133 | source = "registry+https://github.com/rust-lang/crates.io-index" 134 | dependencies = [ 135 | "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 136 | ] 137 | 138 | [[package]] 139 | name = "rand_core" 140 | version = "0.4.0" 141 | source = "registry+https://github.com/rust-lang/crates.io-index" 142 | 143 | [[package]] 144 | name = "rustc_version" 145 | version = "0.2.3" 146 | source = "registry+https://github.com/rust-lang/crates.io-index" 147 | dependencies = [ 148 | "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 149 | ] 150 | 151 | [[package]] 152 | name = "semver" 153 | version = "0.9.0" 154 | source = "registry+https://github.com/rust-lang/crates.io-index" 155 | dependencies = [ 156 | "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 157 | ] 158 | 159 | [[package]] 160 | name = "semver-parser" 161 | version = "0.7.0" 162 | source = "registry+https://github.com/rust-lang/crates.io-index" 163 | 164 | [[package]] 165 | name = "syn" 166 | version = "0.15.29" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | dependencies = [ 169 | "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", 170 | "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", 171 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 172 | ] 173 | 174 | [[package]] 175 | name = "uarte-logger" 176 | version = "0.1.0" 177 | dependencies = [ 178 | "nrf52832-hal 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 179 | ] 180 | 181 | [[package]] 182 | name = "unicode-xid" 183 | version = "0.1.0" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | 186 | [[package]] 187 | name = "vcell" 188 | version = "0.1.0" 189 | source = "registry+https://github.com/rust-lang/crates.io-index" 190 | 191 | [[package]] 192 | name = "void" 193 | version = "1.0.2" 194 | source = "registry+https://github.com/rust-lang/crates.io-index" 195 | 196 | [[package]] 197 | name = "volatile-register" 198 | version = "0.2.0" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | dependencies = [ 201 | "vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 202 | ] 203 | 204 | [metadata] 205 | "checksum aligned 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d39da9b88ae1a81c03c9c082b8db83f1d0e93914126041962af61034ab44c4a5" 206 | "checksum bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3caf393d93b2d453e80638d0674597020cef3382ada454faacd43d1a55a735a" 207 | "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" 208 | "checksum cortex-m 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dab2164a0fc216781a47fc343347365112ae6917421d3fa4bac6faf0fbaaaec7" 209 | "checksum cortex-m-rt 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f69d2beca37acc3776c17201c9d1f8904fb9139fa3a4d2cf28c8436a07b21a88" 210 | "checksum cortex-m-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d7ae692573e0acccb1579fef1abf5a5bf1d2f3f0149a22b16870ec9309aee25f" 211 | "checksum embedded-hal 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9880e55238830314d41d88f1ac7a819d495799c3cc3bc392cc172bab26428c33" 212 | "checksum nb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "69f380b5fe9fab8c0d7a6a99cda23e2cc0463bedb2cbc3aada0813b98496ecdc" 213 | "checksum nrf52-hal-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3de7d61b88c3f51a6d98207ae96a19556660d1f22e77b53f73eeff83cd4ff26e" 214 | "checksum nrf52832-hal 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "357ea63c48c9aa63d07e92262ceab0904697f61775a69a966ff0e33f259a3989" 215 | "checksum nrf52832-pac 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "979c2317388354d7dfc55c7b5098fd6becbb3ea588c7da627f2dcbcfd46a94bf" 216 | "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" 217 | "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" 218 | "checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" 219 | "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" 220 | "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 221 | "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" 222 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 223 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 224 | "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 225 | "checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2" 226 | "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" 227 | "checksum vcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45c297f0afb6928cd08ab1ff9d95e99392595ea25ae1b5ecf822ff8764e57a0d" 228 | "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" 229 | "checksum volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286" 230 | -------------------------------------------------------------------------------- /uarte-logger/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uarte-logger" 3 | version = "0.1.0" 4 | authors = ["James Munns "] 5 | edition = "2018" 6 | 7 | [dependencies.nrf52832-hal] 8 | version = "0.8" 9 | default-features = false 10 | -------------------------------------------------------------------------------- /uarte-logger/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | use nrf52832_hal::{ 4 | uarte::Uarte, 5 | target_constants::EASY_DMA_SIZE, 6 | nrf52832_pac::{ 7 | UARTE0, 8 | }, 9 | }; 10 | 11 | pub struct Logger { 12 | uart: Uarte, 13 | scratch: [u8; EASY_DMA_SIZE], 14 | } 15 | 16 | impl Logger { 17 | pub fn new(uart: Uarte) -> Self { 18 | Self { 19 | uart, 20 | scratch: [0u8; EASY_DMA_SIZE], 21 | } 22 | } 23 | 24 | pub fn log(&mut self, data: &str) -> Result<(), ()> { 25 | self.send("LOG: ".as_bytes())?; 26 | self.send(data.as_bytes())?; 27 | self.send("\r\n".as_bytes()) 28 | } 29 | 30 | pub fn warn(&mut self, data: &str) -> Result<(), ()> { 31 | self.send("WRN: ".as_bytes())?; 32 | self.send(data.as_bytes())?; 33 | self.send("\r\n".as_bytes()) 34 | } 35 | 36 | pub fn error(&mut self, data: &str) -> Result<(), ()> { 37 | self.send("ERR: ".as_bytes())?; 38 | self.send(data.as_bytes())?; 39 | self.send("\r\n".as_bytes()) 40 | } 41 | 42 | fn send(&mut self, buf: &[u8]) -> Result<(), ()> { 43 | for c in buf.chunks(EASY_DMA_SIZE) { 44 | self.scratch[..c.len()] 45 | .copy_from_slice(c); 46 | self.uart.write( 47 | &self.scratch[..c.len()] 48 | ).map_err(|_| ())?; 49 | } 50 | Ok(()) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /uhr/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uhr" 3 | version = "0.2.0" 4 | authors = ["James Munns "] 5 | license = "MIT OR Apache-2.0" 6 | edition = "2018" 7 | repository = "https://github.com/ferrous-systems/internet-of-streams" 8 | documentation = "https://docs.rs/uhr" 9 | description = "A no_std friendly wall clock and alarm clock library" 10 | readme = "README.md" 11 | 12 | [dependencies] 13 | heapless = "0.4.2" 14 | generic-array = "0.11" 15 | gregor = "0.3.2" 16 | bitflags = "1.0" 17 | -------------------------------------------------------------------------------- /uhr/README.md: -------------------------------------------------------------------------------- 1 | # `uhr` - A `no_std` wall clock 2 | 3 | * [Documentation](https://docs.rs/uhr) 4 | 5 | `uhr` aims to provide a generic abstraction for a time zone aware wall clock, as well as alarms associated with wall clock time. 6 | 7 | It is intended to be used with a Real Time Counter, or any other "ticking" peripheral that can be used to increment a counter. 8 | 9 | It is **NOT** a monotonic clock, and is not suitable as a replacement for `Instant`s and other similar structures. Time may move forward or backwards, due to time zone or daylight savings changes, or minor clock corrections provided by a more reliable source. 10 | 11 | -------------------------------------------------------------------------------- /uhr/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(not(test), no_std)] 2 | 3 | pub mod uhr; 4 | pub mod wecker; 5 | 6 | pub use crate::uhr::Uhr; 7 | pub use crate::wecker::{Alarm, DayFlags, Wecker}; 8 | pub use generic_array::ArrayLength; 9 | pub use gregor::{DateTime, FixedOffsetFromUtc, UnixTimestamp}; 10 | -------------------------------------------------------------------------------- /uhr/src/uhr.rs: -------------------------------------------------------------------------------- 1 | use core::cmp::{Ord, Ordering}; 2 | use core::convert::From; 3 | use core::time::Duration; 4 | 5 | use gregor::{DateTime, FixedOffsetFromUtc, UnixTimestamp}; 6 | 7 | /// A clock representing wall-clock-time. Not guaranteed to be 8 | /// monotonic. Time is stored referenced to epoch/UTC time, and a 9 | /// time zone offset may be provided to determine local time 10 | #[derive(Eq, PartialEq, Debug, Copy, Clone)] 11 | pub struct Uhr { 12 | tz_offset: FixedOffsetFromUtc, 13 | seconds: UnixTimestamp, 14 | nanos: u32, 15 | } 16 | 17 | impl From for Uhr { 18 | fn from(uts: UnixTimestamp) -> Self { 19 | Uhr { 20 | seconds: uts, 21 | nanos: 0, 22 | tz_offset: FixedOffsetFromUtc::from_hours_and_minutes(0, 0), 23 | } 24 | } 25 | } 26 | 27 | impl Ord for Uhr { 28 | fn cmp(&self, other: &Uhr) -> Ordering { 29 | let sec_ord = self.seconds.0.cmp(&other.seconds.0); 30 | 31 | match sec_ord { 32 | Ordering::Equal => self.nanos.cmp(&other.nanos), 33 | order => order, 34 | } 35 | } 36 | } 37 | 38 | impl PartialOrd for Uhr { 39 | fn partial_cmp(&self, other: &Uhr) -> Option { 40 | Some(self.cmp(other)) 41 | } 42 | } 43 | 44 | impl Uhr { 45 | /// Increment the current clock by a duration 46 | pub fn increment(&mut self, dur: &Duration) { 47 | self.seconds.0 += dur.as_secs() as i64; // TODO 48 | self.nanos += dur.subsec_nanos(); 49 | if self.nanos >= 1_000_000_000 { 50 | self.nanos -= 1_000_000_000; 51 | self.seconds.0 += 1; 52 | } 53 | } 54 | 55 | /// Create a new clock time at a time `dur` after the current time 56 | pub fn incremented(&self, dur: &Duration) -> Uhr { 57 | let mut new_time = *self; 58 | new_time.increment(dur); 59 | new_time 60 | } 61 | 62 | /// Obtain the duration since a given time. An error is returned if 63 | /// the before time is after now 64 | pub fn try_duration_since(&self, before: &Uhr) -> Result { 65 | if before > self { 66 | return Err(()); 67 | } 68 | 69 | let mut delta_sec = self.seconds.0 - before.seconds.0; 70 | let delta_nanos = if before.nanos > self.nanos { 71 | delta_sec -= 1; 72 | (self.nanos + 1_000_000_000) - before.nanos 73 | } else { 74 | self.nanos - before.nanos 75 | }; 76 | 77 | Ok(Duration::new(delta_sec as u64, delta_nanos)) 78 | } 79 | 80 | /// Obtain the duration since a given time. This function panics if `before` 81 | /// is after the current time. Consider using `try_duration_since()` 82 | pub fn duration_since(&self, before: &Uhr) -> Duration { 83 | self.try_duration_since(before).unwrap() 84 | } 85 | 86 | /// Convert the current wall clock into a local `DateTime` object 87 | pub fn into_local_date_time(&self) -> DateTime { 88 | DateTime::from_timestamp(self.seconds, self.tz_offset) 89 | } 90 | 91 | /// Change the local timezone of the clock 92 | pub fn set_local_time_zone(&mut self, offset: FixedOffsetFromUtc) { 93 | self.tz_offset = offset; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /uhr/src/wecker.rs: -------------------------------------------------------------------------------- 1 | use core::cmp::Ordering; 2 | use core::convert::From; 3 | use core::time::Duration; 4 | 5 | use bitflags::bitflags; 6 | use generic_array::ArrayLength; 7 | use gregor::{DayOfTheWeek, UnixTimestamp}; 8 | use heapless::binary_heap::{BinaryHeap, Min}; 9 | 10 | use crate::uhr::Uhr; 11 | 12 | bitflags! { 13 | /// A bit packed structure representing days of the week 14 | pub struct DayFlags: u8 { 15 | const MONDAY = 0b0000_0001; 16 | const TUESDAY = 0b0000_0010; 17 | const WEDNESDAY = 0b0000_0100; 18 | const THURSDAY = 0b0000_1000; 19 | const FRIDAY = 0b0001_0000; 20 | const SATURDAY = 0b0010_0000; 21 | const SUNDAY = 0b0100_0000; 22 | 23 | const WEEKDAYS = Self::MONDAY.bits | 24 | Self::TUESDAY.bits | 25 | Self::WEDNESDAY.bits | 26 | Self::THURSDAY.bits | 27 | Self::FRIDAY.bits; 28 | const WEEKENDS = Self::SATURDAY.bits | Self::SUNDAY.bits; 29 | } 30 | } 31 | 32 | impl From for DayFlags { 33 | fn from(dow: DayOfTheWeek) -> DayFlags { 34 | match dow { 35 | DayOfTheWeek::Monday => DayFlags::MONDAY, 36 | DayOfTheWeek::Tuesday => DayFlags::TUESDAY, 37 | DayOfTheWeek::Wednesday => DayFlags::WEDNESDAY, 38 | DayOfTheWeek::Thursday => DayFlags::THURSDAY, 39 | DayOfTheWeek::Friday => DayFlags::FRIDAY, 40 | DayOfTheWeek::Saturday => DayFlags::SATURDAY, 41 | DayOfTheWeek::Sunday => DayFlags::SUNDAY, 42 | } 43 | } 44 | } 45 | 46 | impl DayFlags { 47 | fn days_after(&self, today: DayOfTheWeek) -> u32 { 48 | // We must have some recurring item to reschedule 49 | debug_assert!(!self.is_empty()); 50 | 51 | // Render the current day of the week as a bit flag 52 | let cur = DayFlags::from(today); 53 | 54 | // Obtain (u8) versions of our flag structure 55 | let curb = cur.bits(); 56 | let repb = self.bits(); 57 | 58 | // Overlay next week with this week 59 | let cur2: u32 = u32::from(curb | repb) | (u32::from(repb) << 7); 60 | 61 | // Get rid of days this week that have already passed 62 | let cur3 = cur2 >> curb.trailing_zeros() + 1; 63 | 64 | // How many blank days until the next repeat? 65 | let cur4 = cur3.trailing_zeros() + 1; 66 | 67 | // Our alarm does not support intervals greater than a week 68 | debug_assert!(cur4 <= 7); 69 | debug_assert!(cur4 > 0); 70 | 71 | cur4 72 | } 73 | } 74 | 75 | /// An opaque structure representing an alarm that may or may not repeat periodically 76 | #[derive(Debug, Eq, PartialEq)] 77 | pub struct Alarm { 78 | next_time: Uhr, 79 | repeat: DayFlags, 80 | } 81 | 82 | impl Ord for Alarm { 83 | fn cmp(&self, other: &Alarm) -> Ordering { 84 | self.next_time.cmp(&other.next_time) 85 | } 86 | } 87 | 88 | impl PartialOrd for Alarm { 89 | fn partial_cmp(&self, other: &Alarm) -> Option { 90 | Some(self.cmp(other)) 91 | } 92 | } 93 | 94 | #[derive(Debug, Eq, PartialEq)] 95 | pub enum Error { 96 | /// The specified alarm does not occur on its' specified repeat date 97 | AlarmNotOnRepeat, 98 | 99 | /// No space remains to push alarm 100 | AlarmFull, 101 | } 102 | 103 | /// A structure for storing a wall clock with associated alarms. Alarms 104 | /// are stored in a binary heap, in a "soonest first" order. 105 | #[derive(Debug)] 106 | pub struct Wecker 107 | where 108 | ALARMS: ArrayLength, 109 | { 110 | pub time: Uhr, 111 | alarms: BinaryHeap, 112 | } 113 | 114 | impl From for Wecker 115 | where 116 | ALARMS: ArrayLength, 117 | { 118 | fn from(clock: Uhr) -> Self { 119 | Wecker { 120 | time: clock, 121 | alarms: BinaryHeap::new(), 122 | } 123 | } 124 | } 125 | 126 | impl Wecker 127 | where 128 | ALARMS: ArrayLength, 129 | { 130 | /// Create a new wall clock in UTC time, with no alarms 131 | pub fn new(time: UnixTimestamp) -> Self { 132 | Wecker { 133 | time: Uhr::from(time), 134 | alarms: BinaryHeap::new(), 135 | } 136 | } 137 | 138 | pub fn insert_alarm(&mut self, first_time: Uhr, repeat: DayFlags) -> Result<(), Error> { 139 | // If repeats, verify that first instance is on a repeat day 140 | if !repeat.is_empty() { 141 | let ftdt = first_time.into_local_date_time(); 142 | let good = DayFlags::from(ftdt.day_of_the_week()).intersects(repeat); 143 | if !good { 144 | return Err(Error::AlarmNotOnRepeat); 145 | } 146 | } 147 | 148 | self.alarms 149 | .push(Alarm { 150 | next_time: first_time, 151 | repeat, 152 | }) 153 | .map_err(|_| Error::AlarmFull) 154 | } 155 | 156 | /// Process all pending alarms, including rescheduling. If 157 | /// one or more alarms were ready, this function returns `true` 158 | pub fn alarm_ready(&mut self) -> bool { 159 | let mut flag = false; 160 | 161 | while { 162 | self.alarms 163 | .peek() 164 | .map(|alarm| alarm.next_time <= self.time) 165 | .unwrap_or(false) 166 | } { 167 | const ONE_DAY: Duration = Duration::from_secs(24 * 60 * 60); 168 | const ONE_WEEK: Duration = Duration::from_secs(7 * 24 * 60 * 60); 169 | 170 | // We know there is an alarm ready 171 | let mut alarm = self.alarms.pop().unwrap(); 172 | flag = true; 173 | 174 | // Alarm doesn't repeat? All done! 175 | if alarm.repeat.is_empty() { 176 | continue; 177 | } 178 | 179 | // How many days until the next alarm instance? 180 | let days_til = alarm 181 | .repeat 182 | .days_after(self.time.into_local_date_time().day_of_the_week()); 183 | 184 | // Increment the alarm to the next period 185 | alarm.next_time.increment(&(days_til * ONE_DAY)); 186 | 187 | // Just in case we lost a lot of time, bump the week until we are 188 | // actually in the future from now 189 | while alarm.next_time < self.time { 190 | alarm.next_time.increment(&ONE_WEEK); 191 | } 192 | 193 | // We know there is space left, because we just popped one 194 | self.alarms.push(alarm).unwrap(); 195 | } 196 | 197 | flag 198 | } 199 | } 200 | 201 | #[cfg(test)] 202 | mod tests { 203 | use super::*; 204 | #[test] 205 | fn days_until_test() { 206 | assert_eq!( 207 | DayFlags::days_after(&DayFlags::FRIDAY, DayOfTheWeek::Thursday), 208 | 1 209 | ); 210 | 211 | assert_eq!( 212 | DayFlags::days_after(&DayFlags::THURSDAY, DayOfTheWeek::Friday), 213 | 6 214 | ); 215 | 216 | assert_eq!( 217 | DayFlags::days_after(&DayFlags::WEEKDAYS, DayOfTheWeek::Friday), 218 | 3 219 | ); 220 | 221 | assert_eq!( 222 | DayFlags::days_after(&DayFlags::WEEKENDS, DayOfTheWeek::Sunday), 223 | 6 224 | ); 225 | 226 | assert_eq!( 227 | DayFlags::days_after(&DayFlags::THURSDAY, DayOfTheWeek::Thursday), 228 | 7 229 | ); 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "utils" 3 | version = "0.1.0" 4 | authors = ["James Munns "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | nb = "0.1.1" 9 | 10 | 11 | [dependencies.nrf52832-hal] 12 | version = "0.8" 13 | default-features = false 14 | -------------------------------------------------------------------------------- /utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | use nb::{ 4 | block, 5 | }; 6 | 7 | use nrf52832_hal::{ 8 | prelude::*, 9 | timer::Timer, 10 | }; 11 | 12 | pub fn delay(timer: &mut Timer, cycles: u32) where T: TimerExt { 13 | timer.start(cycles); 14 | block!(timer.wait()).expect("wait fail"); 15 | } 16 | --------------------------------------------------------------------------------