Compare commits
521 commits
77d9df588f
...
da9ce32909
Author | SHA1 | Date | |
---|---|---|---|
da9ce32909 | |||
|
d091b3f0a4 | ||
|
886580179f | ||
|
187093e147 | ||
|
f605302791 | ||
|
ec9a07d143 | ||
|
1588fbc256 | ||
|
37d7b0cd06 | ||
|
61bda59d83 | ||
|
ffb55754c8 | ||
|
2f3b3335e1 | ||
|
44282b18fa | ||
|
fb0ab1e42a | ||
|
5767c003cc | ||
|
e173b973ae | ||
|
2a1ace29a3 | ||
|
03b8e36532 | ||
|
7d65c5c4fa | ||
|
a2ea2630f6 | ||
|
4e905bfcba | ||
|
f2c29ba9d8 | ||
|
2b031756c6 | ||
|
ec53b9187d | ||
|
32adddff9c | ||
|
91f135e25b | ||
|
05562b92af | ||
|
93696c912e | ||
|
e89ff7d129 | ||
|
c5d077a2c6 | ||
|
7d3c852613 | ||
|
05e0f12846 | ||
|
4e5a646f8b | ||
|
8680c86894 | ||
|
b88dc137e7 | ||
|
29d79d3af2 | ||
|
da5ecd29f1 | ||
|
6eb447eb58 | ||
|
3efbd60a90 | ||
|
8c4f044ae7 | ||
|
43b878708d | ||
|
4a8abe8028 | ||
|
2d678d6956 | ||
|
8b4bb625be | ||
|
6ef9e564ca | ||
|
1598dd55e4 | ||
|
2436335f9b | ||
|
2537fc6f4f | ||
|
ea4c2ca95d | ||
|
4811c14cc8 | ||
|
dc6639fa4d | ||
|
7c1ecae53f | ||
|
e7270e00f6 | ||
|
2766993099 | ||
|
5e625f274a | ||
|
024097d833 | ||
|
c83d940005 | ||
|
f32b711e4a | ||
|
14de5e5a3c | ||
|
2e4374df1b | ||
|
dc84b4f45a | ||
|
94b2143463 | ||
|
5236df97c6 | ||
|
ccc2ddab66 | ||
|
20bf995c3b | ||
|
255864f46c | ||
|
a716a3f006 | ||
|
a4ca71bc23 | ||
|
32019ed9b7 | ||
|
4c34132337 | ||
|
d1207706c0 | ||
|
f733071908 | ||
|
01f709c1d9 | ||
|
e54c753537 | ||
|
a0f8948c1c | ||
|
e1e99879a6 | ||
|
d78ce3c6ab | ||
|
2571e0416f | ||
|
2e1b5ef58b | ||
|
238cc004f0 | ||
|
0dd0e593c2 | ||
|
0567ad5e74 | ||
|
8a6cb98e45 | ||
|
4340d74e19 | ||
|
2c3de1eeec | ||
|
a978234cc5 | ||
|
042d234f11 | ||
|
639acdd2a3 | ||
|
4472e08bca | ||
|
d9ea5cb015 | ||
|
f5ebdebd96 | ||
|
c7f775dc20 | ||
|
08f1454527 | ||
|
f5e3f31df7 | ||
|
a5c0d1b79f | ||
|
eefaf1b02e | ||
|
3937c53fd8 | ||
|
de1dc272e0 | ||
|
0a19879c5d | ||
|
38d8abef26 | ||
|
ed3da1721a | ||
|
d8821dd7d7 | ||
|
68b3fbe348 | ||
|
10a1a27cc3 | ||
|
52f40b9c9d | ||
|
4972dbd91b | ||
|
6636a5835b | ||
|
2f62376a15 | ||
|
af9c7379f9 | ||
|
52c43f0249 | ||
|
91e6aa3166 | ||
|
376f65e1d3 | ||
|
03f3a3389d | ||
|
d8bd5907ca | ||
|
028ca55f9c | ||
|
87f6634349 | ||
|
462daeeb49 | ||
|
3408e1ddbf | ||
|
e2aa5ef376 | ||
|
b90eef293b | ||
|
f91244bae6 | ||
|
4f649caa81 | ||
|
49546abfec | ||
|
4ecdf31f9b | ||
|
e2f9a48457 | ||
|
f851081e09 | ||
|
ac5b7edb05 | ||
|
914d7c7919 | ||
|
09cfa28a21 | ||
|
8c54df1042 | ||
|
ef78e3283b | ||
|
b6f76b5ab2 | ||
|
3e70601fc7 | ||
|
b07570fce5 | ||
|
a07702ba7b | ||
|
9e4e536769 | ||
|
5223923bd2 | ||
|
d3f8905e93 | ||
|
14435d095f | ||
|
5137ebab56 | ||
|
d4ff7616f9 | ||
|
a4e62314af | ||
|
c120efad5b | ||
|
5e2fd8623a | ||
|
70061e74b2 | ||
|
02b096915f | ||
|
9bdb697cd9 | ||
|
dd69efe708 | ||
|
b88e1a5d71 | ||
|
8f52ee469e | ||
|
1f30ad595b | ||
|
8cbb64226b | ||
|
6f21d5e478 | ||
|
d6e4086a15 | ||
|
c0cd851fb9 | ||
|
a862334dae | ||
|
f3fdeb26a4 | ||
|
3d8cec3b47 | ||
|
976e9f7fba | ||
|
00babd2ec4 | ||
|
abe7f9921e | ||
|
92eb6011d6 | ||
|
f418006508 | ||
|
98263ac220 | ||
|
e9bbfb349c | ||
|
7884babb9d | ||
|
27652798c7 | ||
|
3c6bf3a31a | ||
|
0b8a8e54dc | ||
|
2a38787a83 | ||
|
c4b88b5781 | ||
|
e0c0a618bd | ||
|
c3be54f96b | ||
|
67f5b8d974 | ||
|
1d1fc9afea | ||
|
bd0243d12f | ||
|
662e97f7b5 | ||
|
114dda2fd1 | ||
|
2f750a82bf | ||
|
73d937dc33 | ||
|
cbc67469d3 | ||
|
96cdf9c9e0 | ||
|
6edf7b4688 | ||
|
79f00e54cc | ||
|
317e065517 | ||
|
1123e3fd41 | ||
|
5e1a6a9753 | ||
|
2462a22140 | ||
|
b2a0eb3cb4 | ||
|
ece6203a99 | ||
|
47c7bb2bb5 | ||
|
8a6b71b0bb | ||
|
0e84bd8a91 | ||
|
26e660722c | ||
|
e3b495908c | ||
|
a0799bf270 | ||
|
a2acb3e3dc | ||
|
9a21f70c9f | ||
|
b870e7f257 | ||
|
1ce9418bca | ||
|
c48547b475 | ||
|
e4c4036a46 | ||
|
292dbcc991 | ||
|
cab17434d5 | ||
|
3ae2f140f9 | ||
|
5dbc531671 | ||
|
bce7c73a3a | ||
|
957be1980d | ||
|
92343551aa | ||
|
89cd0e7cca | ||
|
080b5869da | ||
|
1456900281 | ||
|
7b9215c8b9 | ||
|
dfdbcb400c | ||
|
6926e9e071 | ||
|
7056783fa2 | ||
|
27b83fdbcf | ||
|
f64dd8228b | ||
|
b927c22ac0 | ||
|
6dae3c02c0 | ||
|
d05817f89d | ||
|
67e7532b4a | ||
|
32e9867b4e | ||
|
ab3cc7226a | ||
|
b7dd04e3b1 | ||
|
b05217b356 | ||
|
7eb605d116 | ||
|
2655426cd8 | ||
|
3883a5b2de | ||
|
00ff1409cd | ||
|
cfe8561550 | ||
|
0888183666 | ||
|
e3891b09dc | ||
|
95d0cae897 | ||
|
8b0c883443 | ||
|
f6bd4a3f37 | ||
|
18ba56534b | ||
|
060d1f6e6f | ||
|
d5badb94d2 | ||
|
4b0615957f | ||
|
c65ee20cdd | ||
|
a3c6626f40 | ||
|
0579d248ef | ||
|
b0172bb582 | ||
|
bd6fad6b61 | ||
|
a0231ed74c | ||
|
91476eea12 | ||
|
a44ee963ef | ||
|
94af383809 | ||
|
bbe8d3d38a | ||
|
3c414e99cb | ||
|
478cbc6a41 | ||
|
86c48dde41 | ||
|
6a4ac5bd60 | ||
|
1e268a4d3d | ||
|
633c15c2d8 | ||
|
94007ce6e0 | ||
|
9e8035cfb9 | ||
|
84cbf1d198 | ||
|
1a2c8cecde | ||
|
9daa233b61 | ||
|
8b903e8873 | ||
|
3cf94958c6 | ||
|
c818125c22 | ||
|
a8581e242b | ||
|
6bbb870bfa | ||
|
b64b555bbf | ||
|
8ec2e193e2 | ||
|
74739997bd | ||
|
597b5d6337 | ||
|
e6a1fde3ac | ||
|
7ad76f5f60 | ||
|
4d9115b3fb | ||
|
68c8238812 | ||
|
54fa33cbae | ||
|
8d79679bb2 | ||
|
dd6a873447 | ||
|
e80ca5fc67 | ||
|
b780df5f76 | ||
|
3d8c028864 | ||
|
72029ca0c6 | ||
|
8b0cfde9a6 | ||
|
dbe21730cd | ||
|
d08639f643 | ||
|
5154de3b7e | ||
|
7f3805437c | ||
|
ad7d739ddc | ||
|
453aa58b7f | ||
|
268430bd9f | ||
|
3e2b015dc4 | ||
|
6b9470be2c | ||
|
3f45ec6ead | ||
|
e5495b51b4 | ||
|
ab31a02e17 | ||
|
1812ccd276 | ||
|
72c2b06520 | ||
|
871fe3a549 | ||
|
4a4b8c9b8d | ||
|
3e85fb4f52 | ||
|
72a5523c64 | ||
|
673d11f49f | ||
|
044b5c8921 | ||
|
5af0fe8a58 | ||
|
bf36bec9bb | ||
|
3610799618 | ||
|
a516dbd5e2 | ||
|
319e18b399 | ||
|
4ebd8af96f | ||
|
30918c355b | ||
|
5f9bc6def7 | ||
|
f9d8c68fc8 | ||
|
874d5f7c65 | ||
|
03d8f99aa5 | ||
|
9856d21693 | ||
|
f3703ff6bf | ||
|
039d8ed671 | ||
|
d2045be9f3 | ||
|
ecd7888ba9 | ||
|
348c87fc2f | ||
|
7b590334e6 | ||
|
900b104860 | ||
|
5f8f867eae | ||
|
58ef2594e5 | ||
|
367a22cc0e | ||
|
664e4a5c03 | ||
|
44e4a2c9e9 | ||
|
ade27b7f21 | ||
|
41711195e3 | ||
|
ca3c15658d | ||
|
e61136fa4a | ||
|
8a1658ab0e | ||
|
339dd85968 | ||
|
7baa14371b | ||
|
f594ddceec | ||
|
da197b6016 | ||
|
999a2ad829 | ||
|
ba940017ee | ||
|
4452a06e76 | ||
|
441ca8f64d | ||
|
bfb380e8ca | ||
|
7d86919257 | ||
|
83b5797b8d | ||
|
713d84f778 | ||
|
4d307b5a77 | ||
|
84707af5d7 | ||
|
6eaa259342 | ||
|
368893c9cb | ||
|
694ac3a515 | ||
|
d21e9caa80 | ||
|
b378ec4558 | ||
|
b4a2f7fb70 | ||
|
28f5f0baba | ||
|
7fd79857c3 | ||
|
39c5a6c3f7 | ||
|
245c895d09 | ||
|
7bc71a8262 | ||
|
2c691baadd | ||
|
62f4b4ee1e | ||
|
c46172acac | ||
|
7532a06f67 | ||
|
e9cb9badf7 | ||
|
d3c3670a96 | ||
|
50210e8cdc | ||
|
a87b333034 | ||
|
292c1dd0b8 | ||
|
a23fa8dcb2 | ||
|
b282edcc6e | ||
|
56235c97bc | ||
|
52965ae96a | ||
|
d040dfaff9 | ||
|
cf0d227cca | ||
|
35feb1bf23 | ||
|
53dedd2ff5 | ||
|
9031ce7fa7 | ||
|
7f4803ddaf | ||
|
66122aa60f | ||
|
61f1f80e90 | ||
|
69badfb845 | ||
|
50039b17a7 | ||
|
521332bdd1 | ||
|
a6c419d096 | ||
|
f1d5f4ca21 | ||
|
a52841041d | ||
|
7c1e1ee288 | ||
|
41b9a12574 | ||
|
642465a7da | ||
|
4f76f6b9df | ||
|
000b022ae2 | ||
|
4d1fbcd9cd | ||
|
46fc15783d | ||
|
34bc439f17 | ||
|
4d431b3080 | ||
|
9a6ed79ad1 | ||
|
1d05015a1c | ||
|
76fbec74da | ||
|
8d7c3f7de1 | ||
|
ec6cfc1f21 | ||
|
25cc5241b1 | ||
|
f9324201b1 | ||
|
807e573994 | ||
|
854ae5da8f | ||
|
8b9e2efec2 | ||
|
d18a919ab9 | ||
|
ec185b2fd2 | ||
|
ad45725a24 | ||
|
9c32c43cf8 | ||
|
081afca3f0 | ||
|
33bdc9e85f | ||
|
01c1cb2764 | ||
|
8e89e6a313 | ||
|
a5763b4df4 | ||
|
ac76a713e1 | ||
|
891ec5fa5d | ||
|
b48cf5357c | ||
|
92988a3939 | ||
|
e1d2ba07a7 | ||
|
c4b3488f7f | ||
|
fab434ae84 | ||
|
06234e7839 | ||
|
201b5c6ec1 | ||
|
32a75cb764 | ||
|
bfc5929f50 | ||
|
5cba97821f | ||
|
f285a545be | ||
|
8226904b34 | ||
|
85cfacd3cf | ||
|
183f2f6913 | ||
|
0a5820e3ed | ||
|
ded1f9d335 | ||
|
e5c579d9fb | ||
|
495a29ad6e | ||
|
4e9206efb8 | ||
|
27e8ef6e7e | ||
|
89017d338f | ||
|
2f7bba4668 | ||
|
94e559eba7 | ||
|
4e2296e344 | ||
|
bbeba7f014 | ||
|
1d4cd85f71 | ||
|
41e11d86b9 | ||
|
ddbb6c8c31 | ||
|
aee9d5902a | ||
|
68e784ccd6 | ||
|
608c953fc8 | ||
|
e7161aa085 | ||
|
2f2869f195 | ||
|
ec32159576 | ||
|
6fa608f516 | ||
|
7a26cc3764 | ||
|
5ecc9b805d | ||
|
9a4c4fe2c7 | ||
|
ba7ef3c919 | ||
|
3b01023636 | ||
|
e55f31bdc6 | ||
|
24032d0853 | ||
|
ae49e58993 | ||
|
4b5026e197 | ||
|
afd61ed610 | ||
|
7d350fb4c8 | ||
|
c7c5723f8b | ||
|
73e523ab14 | ||
|
2d8ec70f71 | ||
|
e85242af2c | ||
|
a636bace98 | ||
|
4e42eaef7c | ||
|
2da2e57b38 | ||
|
9d6746e650 | ||
|
bb82a1bd60 | ||
|
cab46a7a8c | ||
|
cd27439fca | ||
|
bb9c687a39 | ||
|
06218f9536 | ||
|
38946114d8 | ||
|
d90e35980f | ||
|
797f5c1e5e | ||
|
2991099daa | ||
|
739e5861c2 | ||
|
7cdbae2a5d | ||
|
45a12fd41f | ||
|
6a508b3210 | ||
|
51d5530925 | ||
|
2b09f9efd7 | ||
|
ca2eef5387 | ||
|
eeb6ffce4c | ||
|
8e7361f4ca | ||
|
c74acae7c0 | ||
|
98b06d7646 | ||
|
5bc1e1793d | ||
|
5a8ac21f6b | ||
|
a4350e0398 | ||
|
5cffaf323b | ||
|
daaaf50298 | ||
|
f3008597aa | ||
|
07f2240a19 | ||
|
a76082b104 | ||
|
b843f2546f | ||
|
2a4a714060 | ||
|
b33ef0d7dd | ||
|
aa7fcec009 | ||
|
3a24e6b465 | ||
|
cc6998be30 | ||
|
db56c4fe6f | ||
|
3e399a9690 | ||
|
07c2f169f5 | ||
|
a91f686544 | ||
|
8e92e8718d | ||
|
0f8b3b8c65 | ||
|
3cd6232d43 | ||
|
4bf2178de7 | ||
|
253f6c42ee | ||
|
fd69247d70 | ||
|
af357d2ad0 | ||
|
87d2c66ef4 | ||
|
0b606b57f1 | ||
|
bcd923a4b0 | ||
|
bef76ee057 | ||
|
0febc24de7 | ||
|
d5f0bceb7c | ||
|
5568cb89c3 | ||
|
10ee1c1ae8 | ||
|
ab36329dce | ||
|
803b76df86 |
533 changed files with 18252 additions and 4807 deletions
17
.github/ci/book.sh
vendored
Executable file
17
.github/ci/book.sh
vendored
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
## on push branch=main
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
make -C docs
|
||||
|
||||
export KUBECONFIG=/ci/secrets/kubeconfig.yml
|
||||
POD=$(kubectl -n embassy get po -l app=website -o jsonpath={.items[0].metadata.name})
|
||||
|
||||
mkdir -p build
|
||||
mv docs/book build/book
|
||||
tar -C build -cf book.tar book
|
||||
kubectl exec $POD -- mkdir -p /usr/share/nginx/html
|
||||
kubectl cp book.tar $POD:/usr/share/nginx/html/
|
||||
kubectl exec $POD -- find /usr/share/nginx/html
|
||||
kubectl exec $POD -- tar -C /usr/share/nginx/html -xvf /usr/share/nginx/html/book.tar
|
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
|
@ -9,12 +9,14 @@
|
|||
"rust-analyzer.check.noDefaultFeatures": true,
|
||||
"rust-analyzer.cargo.noDefaultFeatures": true,
|
||||
"rust-analyzer.showUnlinkedFileNotification": false,
|
||||
// uncomment the target of your chip.
|
||||
// Uncomment the target of your chip.
|
||||
//"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
|
||||
//"rust-analyzer.cargo.target": "thumbv7m-none-eabi",
|
||||
"rust-analyzer.cargo.target": "thumbv7em-none-eabi",
|
||||
//"rust-analyzer.cargo.target": "thumbv7em-none-eabihf",
|
||||
//"rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf",
|
||||
"rust-analyzer.cargo.features": [
|
||||
// Comment out these features when working on the examples. Most example crates do not have any cargo features.
|
||||
"stm32f446re",
|
||||
"time-driver-any",
|
||||
"unstable-pac",
|
||||
|
@ -22,9 +24,10 @@
|
|||
"rt",
|
||||
],
|
||||
"rust-analyzer.linkedProjects": [
|
||||
// Uncomment ONE line for the chip you want to work on.
|
||||
// This makes rust-analyzer work on the example crate and all its dependencies.
|
||||
"embassy-stm32/Cargo.toml",
|
||||
// To work on the examples, comment the line above and all of the cargo.features lines,
|
||||
// then uncomment ONE line below to select the chip you want to work on.
|
||||
// This makes rust-analyzer work on the example crate and all its dependencies.
|
||||
// "examples/nrf52840-rtic/Cargo.toml",
|
||||
// "examples/nrf5340/Cargo.toml",
|
||||
// "examples/nrf-rtos-trace/Cargo.toml",
|
||||
|
|
428
LICENSE-CC-BY-SA
Normal file
428
LICENSE-CC-BY-SA
Normal file
|
@ -0,0 +1,428 @@
|
|||
Attribution-ShareAlike 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International Public
|
||||
License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution-ShareAlike 4.0 International Public License ("Public
|
||||
License"). To the extent this Public License may be interpreted as a
|
||||
contract, You are granted the Licensed Rights in consideration of Your
|
||||
acceptance of these terms and conditions, and the Licensor grants You
|
||||
such rights in consideration of benefits the Licensor receives from
|
||||
making the Licensed Material available under these terms and
|
||||
conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. BY-SA Compatible License means a license listed at
|
||||
creativecommons.org/compatiblelicenses, approved by Creative
|
||||
Commons as essentially the equivalent of this Public License.
|
||||
|
||||
d. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
e. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
g. License Elements means the license attributes listed in the name
|
||||
of a Creative Commons Public License. The License Elements of this
|
||||
Public License are Attribution and ShareAlike.
|
||||
|
||||
h. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
i. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
j. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
k. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
l. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
m. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. Additional offer from the Licensor -- Adapted Material.
|
||||
Every recipient of Adapted Material from You
|
||||
automatically receives an offer from the Licensor to
|
||||
exercise the Licensed Rights in the Adapted Material
|
||||
under the conditions of the Adapter's License You apply.
|
||||
|
||||
c. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
b. ShareAlike.
|
||||
|
||||
In addition to the conditions in Section 3(a), if You Share
|
||||
Adapted Material You produce, the following conditions also apply.
|
||||
|
||||
1. The Adapter's License You apply must be a Creative Commons
|
||||
license with the same License Elements, this version or
|
||||
later, or a BY-SA Compatible License.
|
||||
|
||||
2. You must include the text of, or the URI or hyperlink to, the
|
||||
Adapter's License You apply. You may satisfy this condition
|
||||
in any reasonable manner based on the medium, means, and
|
||||
context in which You Share Adapted Material.
|
||||
|
||||
3. You may not offer or impose any additional or different terms
|
||||
or conditions on, or apply any Effective Technological
|
||||
Measures to, Adapted Material that restrict exercise of the
|
||||
rights granted under the Adapter's License You apply.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material,
|
||||
|
||||
including for purposes of Section 3(b); and
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
|
10
README.md
10
README.md
|
@ -2,7 +2,7 @@
|
|||
|
||||
Embassy is the next-generation framework for embedded applications. Write safe, correct and energy-efficient embedded code faster, using the Rust programming language, its async facilities, and the Embassy libraries.
|
||||
|
||||
## <a href="https://embassy.dev/book/dev/index.html">Documentation</a> - <a href="https://docs.embassy.dev/">API reference</a> - <a href="https://embassy.dev/">Website</a> - <a href="https://matrix.to/#/#embassy-rs:matrix.org">Chat</a>
|
||||
## <a href="https://embassy.dev/book/index.html">Documentation</a> - <a href="https://docs.embassy.dev/">API reference</a> - <a href="https://embassy.dev/">Website</a> - <a href="https://matrix.to/#/#embassy-rs:matrix.org">Chat</a>
|
||||
## Rust + async ❤️ embedded
|
||||
|
||||
The Rust programming language is blazingly fast and memory-efficient, with no runtime, garbage collector or OS. It catches a wide variety of bugs at compile time, thanks to its full memory- and thread-safety, and expressive type system.
|
||||
|
@ -18,6 +18,7 @@ Rust's <a href="https://rust-lang.github.io/async-book/">async/await</a> allows
|
|||
- <a href="https://github.com/esp-rs">esp-rs</a>, for the Espressif Systems ESP32 series of chips.
|
||||
- Embassy HAL support for Espressif chips is being developed in the [esp-rs/esp-hal](https://github.com/esp-rs/esp-hal) repository.
|
||||
- Async WiFi, Bluetooth and ESP-NOW is being developed in the [esp-rs/esp-wifi](https://github.com/esp-rs/esp-wifi) repository.
|
||||
- <a href="https://github.com/ch32-rs/ch32-hal">ch32-hal</a>, for the WCH 32-bit RISC-V(CH32V) series of chips.
|
||||
|
||||
- **Time that Just Works** -
|
||||
No more messing with hardware timers. <a href="https://docs.embassy.dev/embassy-time">embassy_time</a> provides Instant, Duration and Timer types that are globally available and never overflow.
|
||||
|
@ -99,12 +100,7 @@ Examples are found in the `examples/` folder separated by the chip manufacturer
|
|||
|
||||
### Running examples
|
||||
|
||||
- Install `probe-rs`.
|
||||
|
||||
```bash
|
||||
cargo install probe-rs --features cli
|
||||
```
|
||||
|
||||
- Install `probe-rs` following the instructions at <https://probe.rs>.
|
||||
- Change directory to the sample's base directory. For example:
|
||||
|
||||
```bash
|
||||
|
|
|
@ -30,4 +30,3 @@ cargo batch \
|
|||
|
||||
cargo build --release --manifest-path embassy-executor/Cargo.toml --target avr-unknown-gnu-atmega328 -Z build-std=core,alloc --features nightly,arch-avr,avr-device/atmega328p
|
||||
cargo build --release --manifest-path embassy-executor/Cargo.toml --target avr-unknown-gnu-atmega328 -Z build-std=core,alloc --features nightly,arch-avr,integrated-timers,avr-device/atmega328p
|
||||
|
||||
|
|
34
ci.sh
34
ci.sh
|
@ -2,6 +2,14 @@
|
|||
|
||||
set -eo pipefail
|
||||
|
||||
if ! command -v cargo-batch &> /dev/null; then
|
||||
echo "cargo-batch could not be found. Install it with the following command:"
|
||||
echo ""
|
||||
echo " cargo install --git https://github.com/embassy-rs/cargo-batch cargo --bin cargo-batch --locked"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export RUSTFLAGS=-Dwarnings
|
||||
export DEFMT_LOG=trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,cyw43=info,cyw43_pio=info,smoltcp=info
|
||||
if [[ -z "${CARGO_TARGET_DIR}" ]]; then
|
||||
|
@ -169,16 +177,20 @@ cargo batch \
|
|||
--- build --release --manifest-path cyw43-pio/Cargo.toml --target thumbv6m-none-eabi --features 'overclock' \
|
||||
--- build --release --manifest-path embassy-boot-nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \
|
||||
--- build --release --manifest-path embassy-boot-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \
|
||||
--- build --release --manifest-path embassy-boot-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9120-ns \
|
||||
--- build --release --manifest-path embassy-boot-rp/Cargo.toml --target thumbv6m-none-eabi \
|
||||
--- build --release --manifest-path embassy-boot-stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \
|
||||
--- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \
|
||||
--- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-pac/Cargo.toml --target thumbv7em-none-eabi \
|
||||
--- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-hal/Cargo.toml --target thumbv7em-none-eabi \
|
||||
--- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-irq/Cargo.toml --target thumbv7em-none-eabi \
|
||||
--- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml --target thumbv7em-none-eabi \
|
||||
--- build --release --manifest-path docs/examples/basic/Cargo.toml --target thumbv7em-none-eabi \
|
||||
--- build --release --manifest-path docs/examples/layer-by-layer/blinky-pac/Cargo.toml --target thumbv7em-none-eabi \
|
||||
--- build --release --manifest-path docs/examples/layer-by-layer/blinky-hal/Cargo.toml --target thumbv7em-none-eabi \
|
||||
--- build --release --manifest-path docs/examples/layer-by-layer/blinky-irq/Cargo.toml --target thumbv7em-none-eabi \
|
||||
--- build --release --manifest-path docs/examples/layer-by-layer/blinky-async/Cargo.toml --target thumbv7em-none-eabi \
|
||||
--- build --release --manifest-path examples/nrf52810/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/nrf52810 \
|
||||
--- build --release --manifest-path examples/nrf52840/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/nrf52840 \
|
||||
--- build --release --manifest-path examples/nrf5340/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/nrf5340 \
|
||||
--- build --release --manifest-path examples/nrf9160/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/nrf9160 \
|
||||
--- build --release --manifest-path examples/nrf9151/s/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/nrf9151/s \
|
||||
--- build --release --manifest-path examples/nrf9151/ns/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/nrf9151/ns \
|
||||
--- build --release --manifest-path examples/nrf51/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/nrf51 \
|
||||
--- build --release --manifest-path examples/rp/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/rp \
|
||||
--- build --release --manifest-path examples/stm32f0/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/stm32f0 \
|
||||
|
@ -187,12 +199,14 @@ cargo batch \
|
|||
--- build --release --manifest-path examples/stm32f3/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32f3 \
|
||||
--- build --release --manifest-path examples/stm32f334/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32f334 \
|
||||
--- build --release --manifest-path examples/stm32f4/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32f4 \
|
||||
--- build --release --manifest-path examples/stm32f469/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32f469 \
|
||||
--- build --release --manifest-path examples/stm32f7/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32f7 \
|
||||
--- build --release --manifest-path examples/stm32c0/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/stm32c0 \
|
||||
--- build --release --manifest-path examples/stm32g0/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/stm32g0 \
|
||||
--- build --release --manifest-path examples/stm32g4/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32g4 \
|
||||
--- build --release --manifest-path examples/stm32h5/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/stm32h5 \
|
||||
--- build --release --manifest-path examples/stm32h7/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h7 \
|
||||
--- build --release --manifest-path examples/stm32h735/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h735 \
|
||||
--- build --release --manifest-path examples/stm32h7rs/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32h7rs \
|
||||
--- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/stm32l0 \
|
||||
--- build --release --manifest-path examples/stm32l1/Cargo.toml --target thumbv7m-none-eabi --out-dir out/examples/stm32l1 \
|
||||
|
@ -205,6 +219,7 @@ cargo batch \
|
|||
--- build --release --manifest-path examples/stm32wl/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32wl \
|
||||
--- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840,skip-include --out-dir out/examples/boot/nrf52840 \
|
||||
--- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns,skip-include --out-dir out/examples/boot/nrf9160 \
|
||||
--- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9120-ns,skip-include --out-dir out/examples/boot/nrf9120 \
|
||||
--- build --release --manifest-path examples/boot/application/rp/Cargo.toml --target thumbv6m-none-eabi --features skip-include --out-dir out/examples/boot/rp \
|
||||
--- build --release --manifest-path examples/boot/application/stm32f3/Cargo.toml --target thumbv7em-none-eabi --features skip-include --out-dir out/examples/boot/stm32f3 \
|
||||
--- build --release --manifest-path examples/boot/application/stm32f7/Cargo.toml --target thumbv7em-none-eabi --features skip-include --out-dir out/examples/boot/stm32f7 \
|
||||
|
@ -216,6 +231,7 @@ cargo batch \
|
|||
--- build --release --manifest-path examples/boot/application/stm32wb-dfu/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/boot/stm32wb-dfu \
|
||||
--- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \
|
||||
--- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \
|
||||
--- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9120-ns \
|
||||
--- build --release --manifest-path examples/boot/bootloader/rp/Cargo.toml --target thumbv6m-none-eabi \
|
||||
--- build --release --manifest-path examples/boot/bootloader/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \
|
||||
--- build --release --manifest-path examples/boot/bootloader/stm32wb-dfu/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wb55rg \
|
||||
|
@ -250,8 +266,12 @@ cargo batch \
|
|||
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32h503rb --out-dir out/tests/stm32h503rb \
|
||||
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32u083rc --out-dir out/tests/stm32u083rc \
|
||||
--- build --release --manifest-path tests/rp/Cargo.toml --target thumbv6m-none-eabi --out-dir out/tests/rpi-pico \
|
||||
--- build --release --manifest-path tests/nrf52840/Cargo.toml --target thumbv7em-none-eabi --out-dir out/tests/nrf52840-dk \
|
||||
--- build --release --manifest-path tests/nrf51422/Cargo.toml --target thumbv6m-none-eabi --out-dir out/tests/nrf51-dk \
|
||||
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv6m-none-eabi --features nrf51422 --out-dir out/tests/nrf51422-dk \
|
||||
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52832 --out-dir out/tests/nrf52832-dk \
|
||||
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833 --out-dir out/tests/nrf52833-dk \
|
||||
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840 --out-dir out/tests/nrf52840-dk \
|
||||
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340 --out-dir out/tests/nrf5340-dk \
|
||||
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160 --out-dir out/tests/nrf9160-dk \
|
||||
--- build --release --manifest-path tests/riscv32/Cargo.toml --target riscv32imac-unknown-none-elf \
|
||||
$BUILD_EXTRA
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ overclock = []
|
|||
|
||||
[dependencies]
|
||||
cyw43 = { version = "0.1.0", path = "../cyw43" }
|
||||
embassy-rp = { version = "0.1.0", path = "../embassy-rp" }
|
||||
embassy-rp = { version = "0.2.0", path = "../embassy-rp" }
|
||||
pio-proc = "0.2"
|
||||
pio = "0.2.1"
|
||||
fixed = "1.23.1"
|
||||
|
|
|
@ -17,10 +17,10 @@ log = ["dep:log"]
|
|||
firmware-logs = []
|
||||
|
||||
[dependencies]
|
||||
embassy-time = { version = "0.3.0", path = "../embassy-time"}
|
||||
embassy-sync = { version = "0.5.0", path = "../embassy-sync"}
|
||||
embassy-time = { version = "0.3.2", path = "../embassy-time"}
|
||||
embassy-sync = { version = "0.6.0", path = "../embassy-sync"}
|
||||
embassy-futures = { version = "0.1.0", path = "../embassy-futures"}
|
||||
embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel"}
|
||||
embassy-net-driver-channel = { version = "0.3.0", path = "../embassy-net-driver-channel"}
|
||||
|
||||
defmt = { version = "0.3", optional = true }
|
||||
log = { version = "0.4.17", optional = true }
|
||||
|
|
|
@ -23,7 +23,7 @@ TODO:
|
|||
|
||||
## Running the examples
|
||||
|
||||
- `cargo install probe-rs --features cli`
|
||||
- Install `probe-rs` following the instructions at <https://probe.rs>.
|
||||
- `cd examples/rp`
|
||||
### Example 1: Scan the wifi stations
|
||||
- `cargo run --release --bin wifi_scan`
|
||||
|
|
|
@ -42,9 +42,11 @@ pub enum ScanType {
|
|||
Passive,
|
||||
}
|
||||
|
||||
/// Scan options.
|
||||
#[derive(Clone)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub struct ScanOptions {
|
||||
/// SSID to scan for.
|
||||
pub ssid: Option<heapless::String<32>>,
|
||||
/// If set to `None`, all APs will be returned. If set to `Some`, only APs
|
||||
/// with the specified BSSID will be returned.
|
||||
|
@ -393,6 +395,24 @@ impl<'a> Control<'a> {
|
|||
self.set_iovar_u32x2("bss", 0, 1).await; // bss = BSS_UP
|
||||
}
|
||||
|
||||
/// Closes access point.
|
||||
pub async fn close_ap(&mut self) {
|
||||
// Stop AP
|
||||
self.set_iovar_u32x2("bss", 0, 0).await; // bss = BSS_DOWN
|
||||
|
||||
// Turn off AP mode
|
||||
self.ioctl_set_u32(IOCTL_CMD_SET_AP, 0, 0).await;
|
||||
|
||||
// Temporarily set wifi down
|
||||
self.down().await;
|
||||
|
||||
// Turn on APSTA mode
|
||||
self.set_iovar_u32("apsta", 1).await;
|
||||
|
||||
// Set wifi up again
|
||||
self.up().await;
|
||||
}
|
||||
|
||||
/// Add specified address to the list of hardware addresses the device
|
||||
/// listens on. The address must be a Group address (I/G bit set). Up
|
||||
/// to 10 addresses are supported by the firmware. Returns the number of
|
||||
|
|
|
@ -6,6 +6,7 @@ use core::fmt::{Debug, Display, LowerHex};
|
|||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ macro_rules! assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ macro_rules! assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -39,6 +42,7 @@ macro_rules! assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -50,6 +54,7 @@ macro_rules! debug_assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -61,6 +66,7 @@ macro_rules! debug_assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -72,6 +78,7 @@ macro_rules! debug_assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -83,20 +90,19 @@ macro_rules! todo {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::core::unreachable!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unreachable!($($x)*)
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
::core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
::defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -108,6 +114,7 @@ macro_rules! panic {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! trace {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -121,6 +128,7 @@ macro_rules! trace {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -134,6 +142,7 @@ macro_rules! debug {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! info {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -147,6 +156,7 @@ macro_rules! info {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! warn {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -160,6 +170,7 @@ macro_rules! warn {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! error {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -174,6 +185,7 @@ macro_rules! error {
|
|||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unwrap!($($x)*)
|
||||
|
@ -181,6 +193,7 @@ macro_rules! unwrap {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
match $crate::fmt::Try::into_result($arg) {
|
||||
|
|
|
@ -28,7 +28,7 @@ use ioctl::IoctlState;
|
|||
|
||||
use crate::bus::Bus;
|
||||
pub use crate::bus::SpiBusCyw43;
|
||||
pub use crate::control::{AddMulticastAddressError, Control, Error as ControlError, Scanner};
|
||||
pub use crate::control::{AddMulticastAddressError, Control, Error as ControlError, ScanOptions, Scanner};
|
||||
pub use crate::runner::Runner;
|
||||
pub use crate::structs::BssInfo;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use embassy_futures::select::{select3, Either3};
|
||||
use embassy_net_driver_channel as ch;
|
||||
use embassy_sync::pubsub::PubSubBehavior;
|
||||
use embassy_time::{block_for, Duration, Timer};
|
||||
use embedded_hal_1::digital::OutputPin;
|
||||
|
||||
|
@ -438,13 +437,16 @@ where
|
|||
// publish() is a deadlock risk in the current design as awaiting here prevents ioctls
|
||||
// The `Runner` always yields when accessing the device, so consumers always have a chance to receive the event
|
||||
// (if they are actively awaiting the queue)
|
||||
self.events.queue.publish_immediate(events::Message::new(
|
||||
Status {
|
||||
event_type: evt_type,
|
||||
status,
|
||||
},
|
||||
event_payload,
|
||||
));
|
||||
self.events
|
||||
.queue
|
||||
.immediate_publisher()
|
||||
.publish_immediate(events::Message::new(
|
||||
Status {
|
||||
event_type: evt_type,
|
||||
status,
|
||||
},
|
||||
event_payload,
|
||||
));
|
||||
}
|
||||
}
|
||||
CHANNEL_TYPE_DATA => {
|
||||
|
|
8
docs/Makefile
Normal file
8
docs/Makefile
Normal file
|
@ -0,0 +1,8 @@
|
|||
all:
|
||||
asciidoctor -d book -D book/ index.adoc
|
||||
cp -r images book
|
||||
|
||||
clean:
|
||||
rm -rf book
|
||||
|
||||
.PHONY: all clean
|
|
@ -1,4 +1,29 @@
|
|||
# embassy docs
|
||||
|
||||
The documentation hosted at [https://embassy.dev/book](https://embassy.dev/book). Building the documentation requires
|
||||
cloning the [embassy-book](https://github.com/embassy-rs/embassy-book) repository and following the instructions.
|
||||
The documentation hosted at [https://embassy.dev/book](https://embassy.dev/book). Building the documentation requires the [asciidoctor](https://asciidoctor.org/) tool, and can built running `make` in this folder:
|
||||
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
Then open the generated file `thebook/index.html`.
|
||||
|
||||
## License
|
||||
|
||||
The Embassy Docs (this folder) is distributed under the following licenses:
|
||||
|
||||
* The code samples and free-standing Cargo projects contained within these docs are licensed under the terms of both the [MIT License] and the [Apache License v2.0].
|
||||
* The written prose contained within these docs are licensed under the terms of the Creative Commons [CC-BY-SA v4.0] license.
|
||||
|
||||
Copies of the licenses used by this project may also be found here:
|
||||
|
||||
* [MIT License Hosted]
|
||||
* [Apache License v2.0 Hosted]
|
||||
* [CC-BY-SA v4.0 Hosted]
|
||||
|
||||
[MIT License]: ./../LICENSE-MIT
|
||||
[Apache License v2.0]: ./../LICENSE-APACHE
|
||||
[CC-BY-SA v4.0]: ./../LICENSE-CC-BY-SA
|
||||
[MIT License Hosted]: https://opensource.org/licenses/MIT
|
||||
[Apache License v2.0 Hosted]: http://www.apache.org/licenses/LICENSE-2.0
|
||||
[CC-BY-SA v4.0 Hosted]: https://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
name: ROOT
|
||||
title: Embassy
|
||||
version: dev
|
||||
nav:
|
||||
- modules/ROOT/nav.adoc
|
18
docs/examples/basic/Cargo.toml
Normal file
18
docs/examples/basic/Cargo.toml
Normal file
|
@ -0,0 +1,18 @@
|
|||
[package]
|
||||
authors = ["Dario Nieuwenhuis <dirbaio@dirbaio.net>"]
|
||||
edition = "2018"
|
||||
name = "embassy-basic-example"
|
||||
version = "0.1.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
embassy-executor = { version = "0.6.0", path = "../../../embassy-executor", features = ["defmt", "integrated-timers", "arch-cortex-m", "executor-thread"] }
|
||||
embassy-time = { version = "0.3.2", path = "../../../embassy-time", features = ["defmt"] }
|
||||
embassy-nrf = { version = "0.2.0", path = "../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] }
|
||||
|
||||
defmt = "0.3"
|
||||
defmt-rtt = "0.3"
|
||||
|
||||
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||
cortex-m-rt = "0.7.0"
|
||||
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
1
docs/examples/examples
Symbolic link
1
docs/examples/examples
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../examples
|
|
@ -8,8 +8,8 @@ members = [
|
|||
]
|
||||
|
||||
[patch.crates-io]
|
||||
embassy-executor = { path = "../../../../../embassy-executor" }
|
||||
embassy-stm32 = { path = "../../../../../embassy-stm32" }
|
||||
embassy-executor = { path = "../../../embassy-executor" }
|
||||
embassy-stm32 = { path = "../../../embassy-stm32" }
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
|
@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
|
|||
cortex-m = "0.7"
|
||||
cortex-m-rt = "0.7"
|
||||
embassy-stm32 = { version = "0.1.0", features = ["stm32l475vg", "memory-x", "exti"] }
|
||||
embassy-executor = { version = "0.5.0", features = ["arch-cortex-m", "executor-thread"] }
|
||||
embassy-executor = { version = "0.6.0", features = ["arch-cortex-m", "executor-thread"] }
|
||||
|
||||
defmt = "0.3.0"
|
||||
defmt-rtt = "0.3.0"
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 131 KiB |
16
docs/index.adoc
Normal file
16
docs/index.adoc
Normal file
|
@ -0,0 +1,16 @@
|
|||
:description: Embassy Book
|
||||
:sectanchors:
|
||||
:doctype: book
|
||||
:toc:
|
||||
:toc-placement: left
|
||||
:toclevels: 2
|
||||
:imagesdir: images
|
||||
|
||||
# Embassy Book
|
||||
|
||||
Welcome to the Embassy Book. The Embassy Book is for everyone who wants to use Embassy and understand how Embassy works.
|
||||
|
||||
include::pages/overview.adoc[leveloffset = 1]
|
||||
include::pages/beginners.adoc[leveloffset = 1]
|
||||
include::pages/system.adoc[leveloffset = 1]
|
||||
include::pages/faq.adoc[leveloffset = 1]
|
|
@ -1,18 +0,0 @@
|
|||
[package]
|
||||
authors = ["Dario Nieuwenhuis <dirbaio@dirbaio.net>"]
|
||||
edition = "2018"
|
||||
name = "embassy-basic-example"
|
||||
version = "0.1.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
embassy-executor = { version = "0.5.0", path = "../../../../../embassy-executor", features = ["defmt", "integrated-timers", "arch-cortex-m", "executor-thread"] }
|
||||
embassy-time = { version = "0.3.0", path = "../../../../../embassy-time", features = ["defmt"] }
|
||||
embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] }
|
||||
|
||||
defmt = "0.3"
|
||||
defmt-rtt = "0.3"
|
||||
|
||||
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||
cortex-m-rt = "0.7.0"
|
||||
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
|
@ -1 +0,0 @@
|
|||
../../../../examples
|
|
@ -1,19 +0,0 @@
|
|||
* xref:getting_started.adoc[Getting started]
|
||||
** xref:basic_application.adoc[Basic application]
|
||||
** xref:project_structure.adoc[Project Structure]
|
||||
** xref:new_project.adoc[Starting a new Embassy project]
|
||||
** xref:best_practices.adoc[Best Practices]
|
||||
* xref:runtime.adoc[Executor]
|
||||
* xref::time_keeping.adoc[Time-keeping]
|
||||
* xref:sharing_peripherals.adoc[Sharing peripherals]
|
||||
* xref:hal.adoc[HAL]
|
||||
** xref:layer_by_layer.adoc[Anatomy of an async HAL]
|
||||
** xref:nrf.adoc[nRF]
|
||||
** xref:stm32.adoc[STM32]
|
||||
* xref:bootloader.adoc[Bootloader]
|
||||
|
||||
* xref:examples.adoc[Examples]
|
||||
* xref:developer.adoc[Developer Docs]
|
||||
** xref:developer_stm32.adoc[Developer Docs: STM32]
|
||||
* xref:embassy_in_the_wild.adoc[Embassy in the wild]
|
||||
* xref:faq.adoc[Frequently Asked Questions]
|
|
@ -1,10 +1,10 @@
|
|||
= A basic Embassy application
|
||||
|
||||
So you've got one of the xref:examples.adoc[examples] running, but what now? Let's go through a simple Embassy application for the nRF52 DK to understand it better.
|
||||
So you've got one of the examples running, but what now? Let's go through a simple Embassy application for the nRF52 DK to understand it better.
|
||||
|
||||
== Main
|
||||
|
||||
The full example can be found link:https://github.com/embassy-rs/embassy/tree/master/docs/modules/ROOT/examples/basic[here].
|
||||
The full example can be found link:https://github.com/embassy-rs/embassy/tree/main/docs/examples/basic[here].
|
||||
|
||||
NOTE: If you’re using VS Code and rust-analyzer to view and edit the examples, you may need to make some changes to `.vscode/settings.json` to tell it which project we’re working on. Follow the instructions commented in that file to get rust-analyzer working correctly.
|
||||
|
||||
|
@ -14,7 +14,7 @@ The first thing you’ll notice are two attributes at the top of the file. These
|
|||
|
||||
[source,rust]
|
||||
----
|
||||
include::example$basic/src/main.rs[lines="1..2"]
|
||||
include::../examples/basic/src/main.rs[lines="1..2"]
|
||||
----
|
||||
|
||||
=== Dealing with errors
|
||||
|
@ -23,7 +23,7 @@ Then, what follows are some declarations on how to deal with panics and faults.
|
|||
|
||||
[source,rust]
|
||||
----
|
||||
include::example$basic/src/main.rs[lines="8"]
|
||||
include::../examples/basic/src/main.rs[lines="8"]
|
||||
----
|
||||
|
||||
=== Task declaration
|
||||
|
@ -32,7 +32,7 @@ After a bit of import declaration, the tasks run by the application should be de
|
|||
|
||||
[source,rust]
|
||||
----
|
||||
include::example$basic/src/main.rs[lines="10..18"]
|
||||
include::../examples/basic/src/main.rs[lines="10..18"]
|
||||
----
|
||||
|
||||
An embassy task must be declared `async`, and may NOT take generic arguments. In this case, we are handed the LED that should be blinked and the interval of the blinking.
|
||||
|
@ -47,7 +47,7 @@ We then initialize the HAL with a default config, which gives us a `Peripherals`
|
|||
|
||||
[source,rust]
|
||||
----
|
||||
include::example$basic/src/main.rs[lines="20..-1"]
|
||||
include::../examples/basic/src/main.rs[lines="20..-1"]
|
||||
----
|
||||
|
||||
What happens when the `blinker` task has been spawned and main returns? Well, the main entry point is actually just like any other task, except that you can only have one and it takes some specific type arguments. The magic lies within the `#[embassy_executor::main]` macro. The macro does the following:
|
||||
|
@ -64,7 +64,7 @@ The project definition needs to contain the embassy dependencies:
|
|||
|
||||
[source,toml]
|
||||
----
|
||||
include::example$basic/Cargo.toml[lines="9..11"]
|
||||
include::../examples/basic/Cargo.toml[lines="9..11"]
|
||||
----
|
||||
|
||||
Depending on your microcontroller, you may need to replace `embassy-nrf` with something else (`embassy-stm32` for STM32. Remember to update feature flags as well).
|
11
docs/pages/beginners.adoc
Normal file
11
docs/pages/beginners.adoc
Normal file
|
@ -0,0 +1,11 @@
|
|||
= For beginners
|
||||
|
||||
The articles in this section are primarily aimed at users new to Embassy,
|
||||
showing how to get started, how to structure your project and other best practices.
|
||||
|
||||
include::getting_started.adoc[leveloffset = 2]
|
||||
include::basic_application.adoc[leveloffset = 2]
|
||||
include::project_structure.adoc[leveloffset = 2]
|
||||
include::new_project.adoc[leveloffset = 2]
|
||||
include::best_practices.adoc[leveloffset = 2]
|
||||
include::layer_by_layer.adoc[leveloffset = 2]
|
|
@ -1,6 +1,6 @@
|
|||
= Embassy in the wild!
|
||||
|
||||
Here are known examples of real-world projects which make use of Embassy. Feel free to link:https://github.com/embassy-rs/embassy/blob/main/docs/modules/ROOT/pages/embassy_in_the_wild.adoc[add more]!
|
||||
Here are known examples of real-world projects which make use of Embassy. Feel free to link:https://github.com/embassy-rs/embassy/blob/main/docs/pages/embassy_in_the_wild.adoc[add more]!
|
||||
|
||||
* link:https://github.com/haobogu/rmk/[RMK: A feature-rich Rust keyboard firmware]
|
||||
** RMK has built-in layer support, wireless(BLE) support, real-time key editing support using vial, and more!
|
||||
|
@ -10,8 +10,8 @@ Here are known examples of real-world projects which make use of Embassy. Feel f
|
|||
* link:https://github.com/card-io-ecg/card-io-fw[Card/IO firmware] - firmware for an open source ECG device
|
||||
** Targets the ESP32-S3 or ESP32-C6 MCU
|
||||
* The link:https://github.com/lora-rs/lora-rs[lora-rs] project includes link:https://github.com/lora-rs/lora-rs/tree/main/examples/stm32l0/src/bin[various standalone examples] for NRF52840, RP2040, STM32L0 and STM32WL
|
||||
** link:https://github.com/matoushybl/air-force-one[Air force one: A simple air quality monitoring system]
|
||||
*** Targets nRF52 and uses nrf-softdevice
|
||||
* link:https://github.com/matoushybl/air-force-one[Air force one: A simple air quality monitoring system]
|
||||
** Targets nRF52 and uses nrf-softdevice
|
||||
|
||||
* link:https://github.com/schmettow/ylab-edge-go[YLab Edge Go] and link:https://github.com/schmettow/ylab-edge-pro[YLab Edge Pro] projects develop
|
||||
firmware (RP2040, STM32) for capturing physiological data in behavioural science research. Included so far are:
|
|
@ -7,5 +7,5 @@ Main loop example
|
|||
|
||||
[source,rust]
|
||||
----
|
||||
include::example$examples/std/src/bin/tick.rs[]
|
||||
include::../examples/examples/std/src/bin/tick.rs[]
|
||||
----
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
These are a list of unsorted, commonly asked questions and answers.
|
||||
|
||||
Please feel free to add items to link:https://github.com/embassy-rs/embassy/edit/main/docs/modules/ROOT/pages/faq.adoc[this page], especially if someone in the chat answered a question for you!
|
||||
Please feel free to add items to link:https://github.com/embassy-rs/embassy/edit/main/docs/pages/faq.adoc[this page], especially if someone in the chat answered a question for you!
|
||||
|
||||
== How to deploy to RP2040 without a debugging probe.
|
||||
|
||||
|
@ -267,10 +267,10 @@ Additionally, some PWR settings require a full device reboot (and enough time to
|
|||
|
||||
There is not a fix for this yet, as it is board/hardware dependant. See link:https://github.com/embassy-rs/embassy/issues/2806[this tracking issue] for more details
|
||||
|
||||
=== STM32 BDMA only work out of some RAM regions
|
||||
=== STM32 BDMA only working out of some RAM regions
|
||||
|
||||
The STM32 BDMA controller included in some chips (TODO: list which ones) has a limitation in that it only works out of certain regions of RAM (TODO: list which ones), otherwise the transfer
|
||||
will fail.
|
||||
The STM32 BDMA controller included in some STM32H7 chips has to be configured to use only certain regions of RAM,
|
||||
otherwise the transfer will fail.
|
||||
|
||||
If you see errors that look like this:
|
||||
|
||||
|
@ -279,7 +279,7 @@ If you see errors that look like this:
|
|||
DMA: error on BDMA@1234ABCD channel 4
|
||||
----
|
||||
|
||||
You need to set up your linker script to define a special region for this area, and copy data to that region before using with BDMA.
|
||||
You need to set up your linker script to define a special region for this area and copy data to that region before using with BDMA.
|
||||
|
||||
General steps:
|
||||
|
||||
|
@ -289,7 +289,7 @@ General steps:
|
|||
4. In your code, access the defined memory region using `#[link_section = ".xxx"]`
|
||||
5. Copy data to that region before using BDMA.
|
||||
|
||||
See link:/examples/stm32h7/src/bin/spi_bdma.rs[this example] for more details.
|
||||
See link:https://github.com/embassy-rs/embassy/blob/main/examples/stm32h7/src/bin/spi_bdma.rs[SMT32H7 SPI BDMA example] for more details.
|
||||
|
||||
== How do I switch to the `main` branch?
|
||||
|
||||
|
@ -299,7 +299,7 @@ You can add a section to your `Cargo.toml` file like this, you'll need to patch
|
|||
|
||||
Using `patch` will replace all direct AND indirect dependencies.
|
||||
|
||||
See the link:https://embassy.dev/book/dev/new_project.html#_cargo_toml[new project docs] for more details on this approach.
|
||||
See the link:https://embassy.dev/book/#_starting_a_new_project[new project docs] for more details on this approach.
|
||||
|
||||
[source,toml]
|
||||
----
|
||||
|
@ -333,3 +333,32 @@ This is not the only possible approach, but if you are looking for where to star
|
|||
8. Then start implementing whatever peripherals you need, like GPIOs, UART, SPI, I2C, etc. This is the largest part of the work, and will likely continue for a while! Don't feel like you need 100% coverage of all peripherals at first, this is likely to be an ongoing process over time.
|
||||
9. Start implementing the embedded-hal, embedded-io, and embedded-hal-async traits on top of your HAL drivers, once you start having more features completed. This will allow users to use standard external device drivers (e.g. sensors, actuators, displays, etc.) with your HAL.
|
||||
10. Discuss upstreaming the PAC/HAL for embassy support, or make sure your drivers are added to the awesome-embedded-rust list so that people can find it.
|
||||
|
||||
== Multiple Tasks, or one task with multiple futures?
|
||||
|
||||
Some examples end like this in main:
|
||||
|
||||
[source,rust]
|
||||
----
|
||||
// Run everything concurrently.
|
||||
// If we had made everything `'static` above instead, we could do this using separate tasks instead.
|
||||
join(usb_fut, join(echo_fut, log_fut)).await;
|
||||
----
|
||||
|
||||
There are two main ways to handle concurrency in Embassy:
|
||||
|
||||
1. Spawn multiple tasks, e.g. with `#[embassy_executor::task]`
|
||||
2. Manage multiple futures inside ONE task using `join()` or `select()` (as shown above)
|
||||
|
||||
In general, either of these approaches will work. The main differences of these approaches are:
|
||||
|
||||
When using **separate tasks**, each task needs its own RAM allocation, so there's a little overhead for each task, so one task that does three things will likely be a little bit smaller than three tasks that do one thing (not a lot, probably a couple dozen bytes). In contrast, with **multiple futures in one task**, you don't need multiple task allocations, and it will generally be easier to share data, or use borrowed resources, inside of a single task.
|
||||
An example showcasing some methods for sharing things between tasks link:https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/sharing.rs[can be found here].
|
||||
|
||||
But when it comes to "waking" tasks, for example when a data transfer is complete or a button is pressed, it's faster to wake a dedicated task, because that task does not need to check which future is actually ready. `join` and `select` must check ALL of the futures they are managing to see which one (or which ones) are ready to do more work. This is because all Rust executors (like Embassy or Tokio) only have the ability to wake tasks, not specific futures. This means you will use slightly less CPU time juggling futures when using dedicated tasks.
|
||||
|
||||
Practically, there's not a LOT of difference either way - so go with what makes it easier for you and your code first, but there will be some details that are slightly different in each case.
|
||||
|
||||
== splitting peripherals resources between tasks
|
||||
|
||||
There are two ways to split resources between tasks, either manually assigned or by a convenient macro. See link:https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/assign_resources.rs[this example]
|
|
@ -131,13 +131,16 @@ If you’re using a raspberry pi pico-w, make sure you’re running `+cargo run
|
|||
|
||||
If you’re using an rp2040 debug probe (e.g. the pico probe) and are having issues after running `probe-rs info`, unplug and reconnect the probe, letting it power cycle. Running `probe-rs info` is link:https://github.com/probe-rs/probe-rs/issues/1849[known to put the pico probe into an unusable state].
|
||||
|
||||
If you’re still having problems, check the link:https://embassy.dev/book/dev/faq.html[FAQ], or ask for help in the link:https://matrix.to/#/#embassy-rs:matrix.org[Embassy Chat Room].
|
||||
:embassy-dev-faq-link-with-hash: https://embassy.dev/book/#_frequently_asked_questions
|
||||
:embassy-matrix-channel: https://matrix.to/#/#embassy-rs:matrix.org
|
||||
|
||||
If you’re still having problems, check the {embassy-dev-faq-link-with-hash}[FAQ], or ask for help in the {embassy-matrix-channel}[Embassy Chat Room].
|
||||
|
||||
== What's next?
|
||||
|
||||
Congratulations, you have your first Embassy application running! Here are some suggestions for where to go from here:
|
||||
|
||||
* Read more about the xref:runtime.adoc[executor].
|
||||
* Read more about the xref:hal.adoc[HAL].
|
||||
* Start xref:basic_application.adoc[writing your application].
|
||||
* Learn how to xref:new_project.adoc[start a new embassy project by adapting an example].
|
||||
* Read more about the xref:_embassy_executor[executor].
|
||||
* Read more about the xref:_hardware_abstraction_layer_hal[HAL].
|
||||
* Start xref:_a_basic_embassy_application[writing your application].
|
||||
* Learn how to xref:_starting_a_new_project[start a new embassy project by adapting an example].
|
|
@ -10,3 +10,5 @@ These HALs implement async/await functionality for most peripherals while also i
|
|||
async traits in `embedded-hal` and `embedded-hal-async`. You can also use these HALs with another executor.
|
||||
|
||||
For the ESP32 series, there is an link:https://github.com/esp-rs/esp-hal[esp-hal] which you can use.
|
||||
|
||||
For the WCH 32-bit RISC-V series, there is an link:https://github.com/ch32-rs/ch32-hal[ch32-hal], which you can use.
|
|
@ -16,7 +16,7 @@ The blinky app using PAC is shown below:
|
|||
|
||||
[source,rust]
|
||||
----
|
||||
include::example$layer-by-layer/blinky-pac/src/main.rs[]
|
||||
include::../examples/layer-by-layer/blinky-pac/src/main.rs[]
|
||||
----
|
||||
|
||||
As you can see, a lot of code is needed to enable the peripheral clocks and to configure the input pins and the output pins of the application.
|
||||
|
@ -35,7 +35,7 @@ The HAL example is shown below:
|
|||
|
||||
[source,rust]
|
||||
----
|
||||
include::example$layer-by-layer/blinky-hal/src/main.rs[]
|
||||
include::../examples/layer-by-layer/blinky-hal/src/main.rs[]
|
||||
----
|
||||
|
||||
As you can see, the application becomes a lot simpler, even without using any async code. The `Input` and `Output` types hide all the details of accessing the GPIO registers and allow you to use a much simpler API for querying the state of the button and toggling the LED output.
|
||||
|
@ -52,7 +52,7 @@ Given Embassy focus on async Rust (which we'll come back to after this example),
|
|||
|
||||
[source,rust]
|
||||
----
|
||||
include::example$layer-by-layer/blinky-irq/src/main.rs[lines="1..57"]
|
||||
include::../examples/layer-by-layer/blinky-irq/src/main.rs[lines="1..57"]
|
||||
----
|
||||
|
||||
The simple application is now more complex again, primarily because of the need to keep the button and LED states in the global scope where it is accessible by the main application loop, as well as the interrupt handler.
|
||||
|
@ -67,7 +67,7 @@ It's time to use the Embassy capabilities to its fullest. At the core, Embassy h
|
|||
|
||||
[source,rust]
|
||||
----
|
||||
include::example$layer-by-layer/blinky-async/src/main.rs[]
|
||||
include::../examples/layer-by-layer/blinky-async/src/main.rs[]
|
||||
----
|
||||
|
||||
The async version looks very similar to the HAL version, apart from a few minor details:
|
||||
|
@ -76,7 +76,7 @@ The async version looks very similar to the HAL version, apart from a few minor
|
|||
* The peripheral initialization is done by the main macro, and is handed to the main task.
|
||||
* Before checking the button state, the application is awaiting a transition in the pin state (low -> high or high -> low).
|
||||
|
||||
When `button.await_for_any_edge().await` is called, the executor will pause the main task and put the microcontroller in sleep mode, unless there are other tasks that can run. Internally, the Embassy HAL has configured the interrupt handler for the button (in `ExtiButton`), so that whenever an interrupt is raised, the task awaiting the button will be woken up.
|
||||
When `button.await_for_any_edge().await` is called, the executor will pause the main task and put the microcontroller in sleep mode, unless there are other tasks that can run. Internally, the Embassy HAL has configured the interrupt handler for the button (in `ExtiInput`), so that whenever an interrupt is raised, the task awaiting the button will be woken up.
|
||||
|
||||
The minimal overhead of the executor and the ability to run multiple tasks "concurrently" combined with the enormous simplification of the application, makes `async` a great fit for embedded.
|
||||
|
|
@ -1,17 +1,18 @@
|
|||
= Starting a new Embassy project
|
||||
= Starting a new project
|
||||
|
||||
Once you’ve successfully xref:getting_started.adoc[run some example projects], the next step is to make a standalone Embassy project.
|
||||
Once you’ve successfully xref:#_getting_started[run some example projects], the next step is to make a standalone Embassy project.
|
||||
|
||||
There are some tools for generating Embassy projects: (WIP)
|
||||
== Tools for generating Embassy projects
|
||||
|
||||
==== CLI
|
||||
=== CLI
|
||||
- link:https://github.com/adinack/cargo-embassy[cargo-embassy] (STM32 and NRF)
|
||||
|
||||
==== cargo-generate
|
||||
=== cargo-generate
|
||||
- link:https://github.com/lulf/embassy-template[embassy-template] (STM32, NRF, and RP)
|
||||
- link:https://github.com/bentwire/embassy-rp2040-template[embassy-rp2040-template] (RP)
|
||||
|
||||
But if you want to start from scratch:
|
||||
|
||||
== Starting a project from scratch
|
||||
|
||||
As an example, let’s create a new embassy project from scratch for a STM32G474. The same instructions are applicable for any supported chip with some minor changes.
|
||||
|
||||
|
@ -35,7 +36,7 @@ stm32g474-example
|
|||
|
||||
Looking in link:https://github.com/embassy-rs/embassy/tree/main/examples[the Embassy examples], we can see there’s a `stm32g4` folder. Find `src/blinky.rs` and copy its contents into our `src/main.rs`.
|
||||
|
||||
== .cargo/config.toml
|
||||
=== The .cargo/config.toml
|
||||
|
||||
Currently, we’d need to provide cargo with a target triple every time we run `cargo build` or `cargo run`. Let’s spare ourselves that work by copying `.cargo/config.toml` from `examples/stm32g4` into our project.
|
||||
|
||||
|
@ -66,7 +67,7 @@ and copying `STM32G474RETx` into `.cargo/config.toml` as so:
|
|||
runner = "probe-rs run --chip STM32G474RETx"
|
||||
----
|
||||
|
||||
== Cargo.toml
|
||||
=== Cargo.toml
|
||||
|
||||
Now that cargo knows what target to compile for (and probe-rs knows what chip to run it on), we’re ready to add some dependencies.
|
||||
|
||||
|
@ -117,7 +118,7 @@ Finally, copy the `[profile.release]` section from the example `Cargo.toml` into
|
|||
debug = 2
|
||||
----
|
||||
|
||||
== rust-toolchain.toml
|
||||
=== rust-toolchain.toml
|
||||
|
||||
Before we can build our project, we need to add an additional file to tell cargo to use the nightly toolchain. Copy the `rust-toolchain.toml` from the embassy repo to ours, and trim the list of targets down to only the target triple relevent for our project — in this case, `thumbv7em-none-eabi`:
|
||||
|
||||
|
@ -142,7 +143,7 @@ components = [ "rust-src", "rustfmt", "llvm-tools", "miri" ]
|
|||
targets = ["thumbv7em-none-eabi"]
|
||||
----
|
||||
|
||||
== build.rs
|
||||
=== build.rs
|
||||
|
||||
In order to produce a working binary for our target, cargo requires a custom build script. Copy `build.rs` from the example to our project:
|
||||
|
||||
|
@ -158,7 +159,7 @@ stm32g474-example
|
|||
└── main.rs
|
||||
----
|
||||
|
||||
== Building and running
|
||||
=== Building and running
|
||||
|
||||
At this point, we‘re finally ready to build and run our project! Connect your board via a debug probe and run:
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
= Embassy nRF HAL
|
||||
|
||||
The link:https://github.com/embassy-rs/embassy/tree/master/embassy-nrf[Embassy nRF HAL] is based on the PACs (Peripheral Access Crate) from link:https://github.com/nrf-rs/[nrf-rs].
|
||||
The link:https://github.com/embassy-rs/embassy/tree/main/embassy-nrf[Embassy nRF HAL] is based on the PACs (Peripheral Access Crate) from link:https://github.com/nrf-rs/[nrf-rs].
|
||||
|
||||
== Timer driver
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
= Embassy
|
||||
= Introduction
|
||||
|
||||
Embassy is a project to make async/await a first-class option for embedded development.
|
||||
|
||||
|
@ -30,6 +30,7 @@ The Embassy project maintains HALs for select hardware, but you can still use HA
|
|||
* link:https://docs.embassy.dev/embassy-nrf/[embassy-nrf], for the Nordic Semiconductor nRF52, nRF53, nRF91 series.
|
||||
* link:https://docs.embassy.dev/embassy-rp/[embassy-rp], for the Raspberry Pi RP2040 microcontroller.
|
||||
* link:https://github.com/esp-rs[esp-rs], for the Espressif Systems ESP32 series of chips.
|
||||
* link:https://github.com/ch32-rs/ch32-hal[ch32-hal], for the WCH 32-bit RISC-V(CH32V) series of chips.
|
||||
|
||||
NOTE: A common question is if one can use the Embassy HALs standalone. Yes, it is possible! There are no dependency on the executor within the HALs. You can even use them without async,
|
||||
as they implement both the link:https://github.com/rust-embedded/embedded-hal[Embedded HAL] blocking and async traits.
|
||||
|
@ -47,7 +48,7 @@ link:https://github.com/lora-rs/lora-rs[lora-rs] supports LoRa networking on a w
|
|||
link:https://docs.embassy.dev/embassy-usb/[embassy-usb] implements a device-side USB stack. Implementations for common classes such as USB serial (CDC ACM) and USB HID are available, and a rich builder API allows building your own.
|
||||
|
||||
=== Bootloader and DFU
|
||||
link:https://github.com/embassy-rs/embassy/tree/master/embassy-boot[embassy-boot] is a lightweight bootloader supporting firmware application upgrades in a power-fail-safe way, with trial boots and rollbacks.
|
||||
link:https://github.com/embassy-rs/embassy/tree/main/embassy-boot[embassy-boot] is a lightweight bootloader supporting firmware application upgrades in a power-fail-safe way, with trial boots and rollbacks.
|
||||
|
||||
== What is DMA?
|
||||
|
||||
|
@ -55,6 +56,20 @@ For most I/O in embedded devices, the peripheral doesn't directly support the tr
|
|||
|
||||
The Direct Memory Access controller (DMA) is a controller that is present in MCUs that Embassy supports, including stm32 and nrf. The DMA allows the MCU to set up a transfer, either send or receive, and then wait for the transfer to complete. With DMA, once started, no MCU intervention is required until the transfer is complete, meaning that the MCU can perform other computation, or set up other I/O while the transfer is in progress. For high I/O rates, DMA can cut the time that the MCU spends handling I/O by over half. However, because DMA is more complex to set-up, it is less widely used in the embedded community. Embassy aims to change that by making DMA the first choice rather than the last. Using Embassy, there's no additional tuning required once I/O rates increase because your application is already set-up to handle them.
|
||||
|
||||
== Examples
|
||||
|
||||
Embassy provides examples for all HALs supported. You can find them in the `examples/` folder.
|
||||
|
||||
|
||||
Main loop example
|
||||
|
||||
[source,rust]
|
||||
----
|
||||
include::../examples/examples/std/src/bin/tick.rs[]
|
||||
----
|
||||
|
||||
include::embassy_in_the_wild.adoc[leveloffset = 2]
|
||||
|
||||
== Resources
|
||||
|
||||
For more reading material on async Rust and Embassy:
|
|
@ -18,6 +18,7 @@ my-project
|
|||
|- rust-toolchain.toml
|
||||
----
|
||||
|
||||
[discrete]
|
||||
== .cargo/config.toml
|
||||
|
||||
This directory/file describes what platform you're on, and configures link:https://github.com/probe-rs/probe-rs[probe-rs] to deploy to your device.
|
||||
|
@ -36,21 +37,27 @@ target = "thumbv6m-none-eabi" # <-change for your platform
|
|||
DEFMT_LOG = "trace" # <- can change to info, warn, or error
|
||||
----
|
||||
|
||||
[discrete]
|
||||
== build.rs
|
||||
|
||||
This is the build script for your project. It links defmt (what is link:https://defmt.ferrous-systems.com[defmt]?) and the `memory.x` file if needed. This file is pretty specific for each chipset, just copy and paste from the corresponding link:https://github.com/embassy-rs/embassy/tree/main/examples[example].
|
||||
|
||||
[discrete]
|
||||
== Cargo.toml
|
||||
|
||||
This is your manifest file, where you can configure all of the embassy components to use the features you need.
|
||||
|
||||
==== Features
|
||||
===== Time
|
||||
[discrete]
|
||||
=== Features
|
||||
|
||||
[discrete]
|
||||
==== Time
|
||||
- tick-hz-x: Configures the tick rate of `embassy-time`. Higher tick rate means higher precision, and higher CPU wakes.
|
||||
- defmt-timestamp-uptime: defmt log entries will display the uptime in seconds.
|
||||
|
||||
...more to come
|
||||
|
||||
[discrete]
|
||||
== memory.x
|
||||
|
||||
This file outlines the flash/ram usage of your program. It is especially useful when using link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] on an nRF5x.
|
||||
|
@ -68,6 +75,7 @@ MEMORY
|
|||
}
|
||||
----
|
||||
|
||||
[discrete]
|
||||
== rust-toolchain.toml
|
||||
|
||||
This file configures the rust version and configuration to use.
|
|
@ -8,7 +8,7 @@ The following examples shows different ways to use the on-board LED on a Raspber
|
|||
|
||||
Using mutual exclusion is the simplest way to share a peripheral.
|
||||
|
||||
TIP: Dependencies needed to run this example link:/book/dev/basic_application.html#_the_cargo_toml[can be found here].
|
||||
TIP: Dependencies needed to run this example link:#_the_cargo_toml[can be found here].
|
||||
[,rust]
|
||||
----
|
||||
use defmt::*;
|
||||
|
@ -78,7 +78,7 @@ To indicate that the pin will be set to an Output. The `AnyPin` could have been
|
|||
|
||||
A channel is another way to ensure exclusive access to a resource. Using a channel is great in the cases where the access can happen at a later point in time, allowing you to enqueue operations and do other things.
|
||||
|
||||
TIP: Dependencies needed to run this example link:/book/dev/basic_application.html#_the_cargo_toml[can be found here].
|
||||
TIP: Dependencies needed to run this example link:#_the_cargo_toml[can be found here].
|
||||
[,rust]
|
||||
----
|
||||
use defmt::*;
|
||||
|
@ -125,4 +125,10 @@ async fn toggle_led(control: Sender<'static, ThreadModeRawMutex, LedState, 64>,
|
|||
----
|
||||
|
||||
This example replaces the Mutex with a Channel, and uses another task (the main loop) to drive the LED. The advantage of this approach is that only a single task references the peripheral, separating concerns. However, using a Mutex has a lower overhead and might be necessary if you need to ensure
|
||||
that the operation is ecompleted before continuing to do other work in your task.
|
||||
that the operation is completed before continuing to do other work in your task.
|
||||
|
||||
An example showcasing more methods for sharing link:https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/sharing.rs[can be found here].
|
||||
|
||||
== Sharing an I2C or SPI bus between multiple devices
|
||||
|
||||
An example of how to deal with multiple devices sharing a common I2C or SPI bus link:https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/shared_bus.rs[can be found here].
|
|
@ -1,6 +1,6 @@
|
|||
= Embassy STM32 HAL
|
||||
|
||||
The link:https://github.com/embassy-rs/embassy/tree/master/embassy-stm32[Embassy STM32 HAL] is based on the `stm32-metapac` project.
|
||||
The link:https://github.com/embassy-rs/embassy/tree/main/embassy-stm32[Embassy STM32 HAL] is based on the `stm32-metapac` project.
|
||||
|
||||
== The infinite variant problem
|
||||
|
13
docs/pages/system.adoc
Normal file
13
docs/pages/system.adoc
Normal file
|
@ -0,0 +1,13 @@
|
|||
= System description
|
||||
|
||||
This section describes different parts of Embassy in more detail.
|
||||
|
||||
include::runtime.adoc[leveloffset = 2]
|
||||
include::bootloader.adoc[leveloffset = 2]
|
||||
include::time_keeping.adoc[leveloffset = 2]
|
||||
include::hal.adoc[leveloffset = 2]
|
||||
include::nrf.adoc[leveloffset = 2]
|
||||
include::stm32.adoc[leveloffset = 2]
|
||||
include::sharing_peripherals.adoc[leveloffset = 2]
|
||||
include::developer.adoc[leveloffset = 2]
|
||||
include::developer_stm32.adoc[leveloffset = 2]
|
|
@ -16,7 +16,7 @@ The `embassy::time::Timer` type provides two timing methods.
|
|||
|
||||
An example of a delay is provided as follows:
|
||||
|
||||
TIP: Dependencies needed to run this example link:/book/dev/basic_application.html#_the_cargo_toml[can be found here].
|
||||
TIP: Dependencies needed to run this example link:#_the_cargo_toml[can be found here].
|
||||
[,rust]
|
||||
----
|
||||
use embassy::executor::{task, Executor};
|
||||
|
@ -41,7 +41,7 @@ that expect a generic delay implementation to be provided.
|
|||
|
||||
An example of how this can be used:
|
||||
|
||||
TIP: Dependencies needed to run this example link:/book/dev/basic_application.html#_the_cargo_toml[can be found here].
|
||||
TIP: Dependencies needed to run this example link:#_the_cargo_toml[can be found here].
|
||||
[,rust]
|
||||
----
|
||||
use embassy::executor::{task, Executor};
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
name = "embassy-boot-nrf"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
description = "Bootloader lib for nRF chips"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/embassy-rs/embassy"
|
||||
|
@ -22,10 +22,11 @@ target = "thumbv7em-none-eabi"
|
|||
|
||||
[dependencies]
|
||||
defmt = { version = "0.3", optional = true }
|
||||
log = { version = "0.4.17", optional = true }
|
||||
|
||||
embassy-sync = { version = "0.5.0", path = "../embassy-sync" }
|
||||
embassy-nrf = { version = "0.1.0", path = "../embassy-nrf", default-features = false }
|
||||
embassy-boot = { version = "0.2.0", path = "../embassy-boot" }
|
||||
embassy-sync = { version = "0.6.0", path = "../embassy-sync" }
|
||||
embassy-nrf = { version = "0.2.0", path = "../embassy-nrf", default-features = false }
|
||||
embassy-boot = { version = "0.3.0", path = "../embassy-boot" }
|
||||
cortex-m = { version = "0.7.6" }
|
||||
cortex-m-rt = { version = "0.7" }
|
||||
embedded-storage = "0.3.1"
|
||||
|
|
|
@ -6,6 +6,7 @@ use core::fmt::{Debug, Display, LowerHex};
|
|||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ macro_rules! assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ macro_rules! assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -39,6 +42,7 @@ macro_rules! assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -50,6 +54,7 @@ macro_rules! debug_assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -61,6 +66,7 @@ macro_rules! debug_assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -72,6 +78,7 @@ macro_rules! debug_assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -83,20 +90,19 @@ macro_rules! todo {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::core::unreachable!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unreachable!($($x)*)
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
::core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
::defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -108,6 +114,7 @@ macro_rules! panic {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! trace {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -121,6 +128,7 @@ macro_rules! trace {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -134,6 +142,7 @@ macro_rules! debug {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! info {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -147,6 +156,7 @@ macro_rules! info {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! warn {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -160,6 +170,7 @@ macro_rules! warn {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! error {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -174,6 +185,7 @@ macro_rules! error {
|
|||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unwrap!($($x)*)
|
||||
|
@ -181,6 +193,7 @@ macro_rules! unwrap {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
match $crate::fmt::Try::into_result($arg) {
|
||||
|
|
|
@ -20,7 +20,13 @@ impl<const BUFFER_SIZE: usize> BootLoader<BUFFER_SIZE> {
|
|||
pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>(
|
||||
config: BootLoaderConfig<ACTIVE, DFU, STATE>,
|
||||
) -> Self {
|
||||
Self::try_prepare::<ACTIVE, DFU, STATE>(config).expect("Boot prepare error")
|
||||
if let Ok(loader) = Self::try_prepare::<ACTIVE, DFU, STATE>(config) {
|
||||
loader
|
||||
} else {
|
||||
// Use explicit panic instead of .expect() to ensure this gets routed via defmt/etc.
|
||||
// properly
|
||||
panic!("Boot prepare error")
|
||||
}
|
||||
}
|
||||
|
||||
/// Inspect the bootloader state and perform actions required before booting, such as swapping firmware
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
name = "embassy-boot-rp"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
description = "Bootloader lib for RP2040 chips"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/embassy-rs/embassy"
|
||||
|
@ -21,13 +21,12 @@ target = "thumbv6m-none-eabi"
|
|||
|
||||
[dependencies]
|
||||
defmt = { version = "0.3", optional = true }
|
||||
defmt-rtt = { version = "0.4", optional = true }
|
||||
log = { version = "0.4", optional = true }
|
||||
|
||||
embassy-sync = { version = "0.5.0", path = "../embassy-sync" }
|
||||
embassy-rp = { version = "0.1.0", path = "../embassy-rp", default-features = false }
|
||||
embassy-boot = { version = "0.2.0", path = "../embassy-boot" }
|
||||
embassy-time = { version = "0.3.0", path = "../embassy-time" }
|
||||
embassy-sync = { version = "0.6.0", path = "../embassy-sync" }
|
||||
embassy-rp = { version = "0.2.0", path = "../embassy-rp", default-features = false }
|
||||
embassy-boot = { version = "0.3.0", path = "../embassy-boot" }
|
||||
embassy-time = { version = "0.3.2", path = "../embassy-time" }
|
||||
|
||||
cortex-m = { version = "0.7.6" }
|
||||
cortex-m-rt = { version = "0.7" }
|
||||
|
@ -46,7 +45,6 @@ log = [
|
|||
"embassy-boot/log",
|
||||
"embassy-rp/log",
|
||||
]
|
||||
debug = ["defmt-rtt"]
|
||||
|
||||
[profile.dev]
|
||||
debug = 2
|
||||
|
|
|
@ -5,4 +5,5 @@ fn main() {
|
|||
if target.starts_with("thumbv6m-") {
|
||||
println!("cargo:rustc-cfg=armv6m");
|
||||
}
|
||||
println!("cargo:rustc-check-cfg=cfg(armv6m)");
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use core::fmt::{Debug, Display, LowerHex};
|
|||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ macro_rules! assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ macro_rules! assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -39,6 +42,7 @@ macro_rules! assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -50,6 +54,7 @@ macro_rules! debug_assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -61,6 +66,7 @@ macro_rules! debug_assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -72,6 +78,7 @@ macro_rules! debug_assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -83,20 +90,19 @@ macro_rules! todo {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::core::unreachable!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unreachable!($($x)*)
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
::core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
::defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -108,6 +114,7 @@ macro_rules! panic {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! trace {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -121,6 +128,7 @@ macro_rules! trace {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -134,6 +142,7 @@ macro_rules! debug {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! info {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -147,6 +156,7 @@ macro_rules! info {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! warn {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -160,6 +170,7 @@ macro_rules! warn {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! error {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -174,6 +185,7 @@ macro_rules! error {
|
|||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unwrap!($($x)*)
|
||||
|
@ -181,6 +193,7 @@ macro_rules! unwrap {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
match $crate::fmt::Try::into_result($arg) {
|
||||
|
|
|
@ -21,7 +21,13 @@ impl<const BUFFER_SIZE: usize> BootLoader<BUFFER_SIZE> {
|
|||
pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>(
|
||||
config: BootLoaderConfig<ACTIVE, DFU, STATE>,
|
||||
) -> Self {
|
||||
Self::try_prepare::<ACTIVE, DFU, STATE>(config).expect("Boot prepare error")
|
||||
if let Ok(loader) = Self::try_prepare::<ACTIVE, DFU, STATE>(config) {
|
||||
loader
|
||||
} else {
|
||||
// Use explicit panic instead of .expect() to ensure this gets routed via defmt/etc.
|
||||
// properly
|
||||
panic!("Boot prepare error")
|
||||
}
|
||||
}
|
||||
|
||||
/// Inspect the bootloader state and perform actions required before booting, such as swapping firmware
|
||||
|
|
|
@ -13,7 +13,7 @@ categories = [
|
|||
]
|
||||
|
||||
[package.metadata.embassy_docs]
|
||||
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-nrf-v$VERSION/embassy-boot-stm32/src/"
|
||||
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-boot-stm32-v$VERSION/embassy-boot-stm32/src/"
|
||||
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-boot-stm32/src/"
|
||||
features = ["embassy-stm32/stm32f429zi"]
|
||||
target = "thumbv7em-none-eabi"
|
||||
|
@ -22,12 +22,11 @@ target = "thumbv7em-none-eabi"
|
|||
|
||||
[dependencies]
|
||||
defmt = { version = "0.3", optional = true }
|
||||
defmt-rtt = { version = "0.4", optional = true }
|
||||
log = { version = "0.4", optional = true }
|
||||
|
||||
embassy-sync = { version = "0.5.0", path = "../embassy-sync" }
|
||||
embassy-sync = { version = "0.6.0", path = "../embassy-sync" }
|
||||
embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false }
|
||||
embassy-boot = { version = "0.2.0", path = "../embassy-boot" }
|
||||
embassy-boot = { version = "0.3.0", path = "../embassy-boot" }
|
||||
cortex-m = { version = "0.7.6" }
|
||||
cortex-m-rt = { version = "0.7" }
|
||||
embedded-storage = "0.3.1"
|
||||
|
@ -37,7 +36,6 @@ cfg-if = "1.0.0"
|
|||
[features]
|
||||
defmt = ["dep:defmt", "embassy-boot/defmt", "embassy-stm32/defmt"]
|
||||
log = ["dep:log", "embassy-boot/log", "embassy-stm32/log"]
|
||||
debug = ["defmt-rtt"]
|
||||
|
||||
[profile.dev]
|
||||
debug = 2
|
||||
|
|
|
@ -5,4 +5,5 @@ fn main() {
|
|||
if target.starts_with("thumbv6m-") {
|
||||
println!("cargo:rustc-cfg=armv6m");
|
||||
}
|
||||
println!("cargo:rustc-check-cfg=cfg(armv6m)");
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use core::fmt::{Debug, Display, LowerHex};
|
|||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ macro_rules! assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ macro_rules! assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -39,6 +42,7 @@ macro_rules! assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -50,6 +54,7 @@ macro_rules! debug_assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -61,6 +66,7 @@ macro_rules! debug_assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -72,6 +78,7 @@ macro_rules! debug_assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -83,20 +90,19 @@ macro_rules! todo {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::core::unreachable!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unreachable!($($x)*)
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
::core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
::defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -108,6 +114,7 @@ macro_rules! panic {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! trace {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -121,6 +128,7 @@ macro_rules! trace {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -134,6 +142,7 @@ macro_rules! debug {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! info {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -147,6 +156,7 @@ macro_rules! info {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! warn {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -160,6 +170,7 @@ macro_rules! warn {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! error {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -174,6 +185,7 @@ macro_rules! error {
|
|||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unwrap!($($x)*)
|
||||
|
@ -181,6 +193,7 @@ macro_rules! unwrap {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
match $crate::fmt::Try::into_result($arg) {
|
||||
|
|
|
@ -20,7 +20,13 @@ impl BootLoader {
|
|||
pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash, const BUFFER_SIZE: usize>(
|
||||
config: BootLoaderConfig<ACTIVE, DFU, STATE>,
|
||||
) -> Self {
|
||||
Self::try_prepare::<ACTIVE, DFU, STATE, BUFFER_SIZE>(config).expect("Boot prepare error")
|
||||
if let Ok(loader) = Self::try_prepare::<ACTIVE, DFU, STATE, BUFFER_SIZE>(config) {
|
||||
loader
|
||||
} else {
|
||||
// Use explicit panic instead of .expect() to ensure this gets routed via defmt/etc.
|
||||
// properly
|
||||
panic!("Boot prepare error")
|
||||
}
|
||||
}
|
||||
|
||||
/// Inspect the bootloader state and perform actions required before booting, such as swapping firmware
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
edition = "2021"
|
||||
name = "embassy-boot"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
description = "A lightweight bootloader supporting firmware updates in a power-fail-safe way, with trial boots and rollbacks."
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/embassy-rs/embassy"
|
||||
|
@ -28,8 +28,8 @@ defmt = { version = "0.3", optional = true }
|
|||
digest = "0.10"
|
||||
log = { version = "0.4", optional = true }
|
||||
ed25519-dalek = { version = "2", default_features = false, features = ["digest"], optional = true }
|
||||
embassy-embedded-hal = { version = "0.1.0", path = "../embassy-embedded-hal" }
|
||||
embassy-sync = { version = "0.5.0", path = "../embassy-sync" }
|
||||
embassy-embedded-hal = { version = "0.2.0", path = "../embassy-embedded-hal" }
|
||||
embassy-sync = { version = "0.6.0", path = "../embassy-sync" }
|
||||
embedded-storage = "0.3.1"
|
||||
embedded-storage-async = { version = "0.4.1" }
|
||||
salty = { version = "0.3", optional = true }
|
||||
|
|
|
@ -24,7 +24,7 @@ For any partition, the following preconditions are required:
|
|||
|
||||
The linker scripts for the application and bootloader look similar, but the FLASH region must point to the BOOTLOADER partition for the bootloader, and the ACTIVE partition for the application.
|
||||
|
||||
For more details on the bootloader, see [the documentation](https://embassy.dev/book/dev/bootloader.html).
|
||||
For more details on the bootloader, see [the documentation](https://embassy.dev/book/#_bootloader).
|
||||
|
||||
## Hardware support
|
||||
|
||||
|
|
|
@ -235,12 +235,15 @@ impl<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash> BootLoader<ACTIVE, DFU, S
|
|||
/// | DFU | 3 | 4 | 5 | 6 | 3 |
|
||||
///
|
||||
pub fn prepare_boot(&mut self, aligned_buf: &mut [u8]) -> Result<State, BootError> {
|
||||
const {
|
||||
core::assert!(Self::PAGE_SIZE % ACTIVE::WRITE_SIZE as u32 == 0);
|
||||
core::assert!(Self::PAGE_SIZE % ACTIVE::ERASE_SIZE as u32 == 0);
|
||||
core::assert!(Self::PAGE_SIZE % DFU::WRITE_SIZE as u32 == 0);
|
||||
core::assert!(Self::PAGE_SIZE % DFU::ERASE_SIZE as u32 == 0);
|
||||
}
|
||||
|
||||
// Ensure we have enough progress pages to store copy progress
|
||||
assert_eq!(0, Self::PAGE_SIZE % aligned_buf.len() as u32);
|
||||
assert_eq!(0, Self::PAGE_SIZE % ACTIVE::WRITE_SIZE as u32);
|
||||
assert_eq!(0, Self::PAGE_SIZE % ACTIVE::ERASE_SIZE as u32);
|
||||
assert_eq!(0, Self::PAGE_SIZE % DFU::WRITE_SIZE as u32);
|
||||
assert_eq!(0, Self::PAGE_SIZE % DFU::ERASE_SIZE as u32);
|
||||
assert!(aligned_buf.len() >= STATE::WRITE_SIZE);
|
||||
assert_eq!(0, aligned_buf.len() % ACTIVE::WRITE_SIZE);
|
||||
assert_eq!(0, aligned_buf.len() % DFU::WRITE_SIZE);
|
||||
|
|
|
@ -6,6 +6,7 @@ use core::fmt::{Debug, Display, LowerHex};
|
|||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ macro_rules! assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ macro_rules! assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -39,6 +42,7 @@ macro_rules! assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -50,6 +54,7 @@ macro_rules! debug_assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -61,6 +66,7 @@ macro_rules! debug_assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -72,6 +78,7 @@ macro_rules! debug_assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -83,20 +90,19 @@ macro_rules! todo {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::core::unreachable!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unreachable!($($x)*)
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
::core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
::defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -108,6 +114,7 @@ macro_rules! panic {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! trace {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -121,6 +128,7 @@ macro_rules! trace {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -134,6 +142,7 @@ macro_rules! debug {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! info {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -147,6 +156,7 @@ macro_rules! info {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! warn {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -160,6 +170,7 @@ macro_rules! warn {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! error {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -174,6 +185,7 @@ macro_rules! error {
|
|||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unwrap!($($x)*)
|
||||
|
@ -181,6 +193,7 @@ macro_rules! unwrap {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
match $crate::fmt::Try::into_result($arg) {
|
||||
|
|
|
@ -43,7 +43,7 @@ where
|
|||
}
|
||||
|
||||
fn create_partition<T: NorFlash>(mutex: &Mutex<NoopRawMutex, T>) -> Partition<NoopRawMutex, T> {
|
||||
Partition::new(mutex, 0, mutex.try_lock().unwrap().capacity() as u32)
|
||||
Partition::new(mutex, 0, unwrap!(mutex.try_lock()).capacity() as u32)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
21
embassy-embedded-hal/CHANGELOG.md
Normal file
21
embassy-embedded-hal/CHANGELOG.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Changelog for embassy-embedded-hal
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 0.2.0 - 2024-08-05
|
||||
|
||||
- Add Clone derive to flash Partition in embassy-embedded-hal
|
||||
- Add support for all word sizes to async shared spi
|
||||
- Add Copy and 'static constraint to Word type in SPI structs
|
||||
- Improve flexibility by introducing SPI word size as a generic parameter
|
||||
- Allow changing Spi/I2cDeviceWithConfig's config at runtime
|
||||
- Impl `MultiwriteNorFlash` for `BlockingAsync`
|
||||
|
||||
## 0.1.0 - 2024-01-10
|
||||
|
||||
- First release
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "embassy-embedded-hal"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "Collection of utilities to use `embedded-hal` and `embedded-storage` traits with Embassy."
|
||||
|
@ -28,8 +28,8 @@ default = ["time"]
|
|||
|
||||
[dependencies]
|
||||
embassy-futures = { version = "0.1.0", path = "../embassy-futures" }
|
||||
embassy-sync = { version = "0.5.0", path = "../embassy-sync" }
|
||||
embassy-time = { version = "0.3.0", path = "../embassy-time", optional = true }
|
||||
embassy-sync = { version = "0.6.0", path = "../embassy-sync" }
|
||||
embassy-time = { version = "0.3.2", path = "../embassy-time", optional = true }
|
||||
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [
|
||||
"unproven",
|
||||
] }
|
||||
|
|
|
@ -18,6 +18,16 @@ pub struct Partition<'a, M: RawMutex, T: NorFlash> {
|
|||
size: u32,
|
||||
}
|
||||
|
||||
impl<'a, M: RawMutex, T: NorFlash> Clone for Partition<'a, M, T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
flash: self.flash,
|
||||
offset: self.offset,
|
||||
size: self.size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, M: RawMutex, T: NorFlash> Partition<'a, M, T> {
|
||||
/// Create a new partition
|
||||
pub const fn new(flash: &'a Mutex<M, T>, offset: u32, size: u32) -> Self {
|
||||
|
|
|
@ -19,6 +19,16 @@ pub struct BlockingPartition<'a, M: RawMutex, T: NorFlash> {
|
|||
size: u32,
|
||||
}
|
||||
|
||||
impl<'a, M: RawMutex, T: NorFlash> Clone for BlockingPartition<'a, M, T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
flash: self.flash,
|
||||
offset: self.offset,
|
||||
size: self.size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, M: RawMutex, T: NorFlash> BlockingPartition<'a, M, T> {
|
||||
/// Create a new partition
|
||||
pub const fn new(flash: &'a Mutex<M, RefCell<T>>, offset: u32, size: u32) -> Self {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "embassy-executor-macros"
|
||||
version = "0.4.1"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "macros for creating the entry point and tasks for embassy-executor"
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn wasm() -> TokenStream {
|
|||
let executor = ::std::boxed::Box::leak(::std::boxed::Box::new(::embassy_executor::Executor::new()));
|
||||
|
||||
executor.start(|spawner| {
|
||||
spawner.spawn(__embassy_main(spawner)).unwrap();
|
||||
spawner.must_spawn(__embassy_main(spawner));
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## Unreleased
|
||||
|
||||
## 0.6.0 - 2024-08-05
|
||||
|
||||
- Add collapse_debuginfo to fmt.rs macros.
|
||||
- initial support for avr
|
||||
- use nightly waker_getters APIs
|
||||
|
||||
## 0.5.0 - 2024-01-11
|
||||
|
||||
- Updated to `embassy-time-driver 0.1`, `embassy-time-queue-driver 0.1`, compatible with `embassy-time v0.3` and higher.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "embassy-executor"
|
||||
version = "0.5.0"
|
||||
version = "0.6.0"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "async/await executor designed for embedded usage"
|
||||
|
@ -33,7 +33,7 @@ defmt = { version = "0.3", optional = true }
|
|||
log = { version = "0.4.14", optional = true }
|
||||
rtos-trace = { version = "0.1.2", optional = true }
|
||||
|
||||
embassy-executor-macros = { version = "0.4.0", path = "../embassy-executor-macros" }
|
||||
embassy-executor-macros = { version = "0.5.0", path = "../embassy-executor-macros" }
|
||||
embassy-time-driver = { version = "0.1.0", path = "../embassy-time-driver", optional = true }
|
||||
embassy-time-queue-driver = { version = "0.1.0", path = "../embassy-time-queue-driver", optional = true }
|
||||
critical-section = "1.1"
|
||||
|
|
|
@ -3,6 +3,9 @@ use std::fmt::Write;
|
|||
use std::path::PathBuf;
|
||||
use std::{env, fs};
|
||||
|
||||
#[path = "./build_common.rs"]
|
||||
mod common;
|
||||
|
||||
static CONFIGS: &[(&str, usize)] = &[
|
||||
// BEGIN AUTOGENERATED CONFIG FEATURES
|
||||
// Generated by gen_config.py. DO NOT EDIT.
|
||||
|
@ -91,30 +94,6 @@ fn main() {
|
|||
let out_file = out_dir.join("config.rs").to_string_lossy().to_string();
|
||||
fs::write(out_file, data).unwrap();
|
||||
|
||||
// cortex-m targets
|
||||
let target = env::var("TARGET").unwrap();
|
||||
|
||||
if target.starts_with("thumbv6m-") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv6m");
|
||||
} else if target.starts_with("thumbv7m-") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv7m");
|
||||
} else if target.starts_with("thumbv7em-") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv7m");
|
||||
println!("cargo:rustc-cfg=armv7em"); // (not currently used)
|
||||
} else if target.starts_with("thumbv8m.base") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv8m");
|
||||
println!("cargo:rustc-cfg=armv8m_base");
|
||||
} else if target.starts_with("thumbv8m.main") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv8m");
|
||||
println!("cargo:rustc-cfg=armv8m_main");
|
||||
}
|
||||
|
||||
if target.ends_with("-eabihf") {
|
||||
println!("cargo:rustc-cfg=has_fpu");
|
||||
}
|
||||
let mut rustc_cfgs = common::CfgSet::new();
|
||||
common::set_target_cfgs(&mut rustc_cfgs);
|
||||
}
|
||||
|
|
94
embassy-executor/build_common.rs
Normal file
94
embassy-executor/build_common.rs
Normal file
|
@ -0,0 +1,94 @@
|
|||
// NOTE: this file is copy-pasted between several Embassy crates, because there is no
|
||||
// straightforward way to share this code:
|
||||
// - it cannot be placed into the root of the repo and linked from each build.rs using `#[path =
|
||||
// "../build_common.rs"]`, because `cargo publish` requires that all files published with a crate
|
||||
// reside in the crate's directory,
|
||||
// - it cannot be symlinked from `embassy-xxx/build_common.rs` to `../build_common.rs`, because
|
||||
// symlinks don't work on Windows.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::env;
|
||||
|
||||
/// Helper for emitting cargo instruction for enabling configs (`cargo:rustc-cfg=X`) and declaring
|
||||
/// them (`cargo:rust-check-cfg=cfg(X)`).
|
||||
#[derive(Debug)]
|
||||
pub struct CfgSet {
|
||||
enabled: HashSet<String>,
|
||||
declared: HashSet<String>,
|
||||
}
|
||||
|
||||
impl CfgSet {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
enabled: HashSet::new(),
|
||||
declared: HashSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Enable a config, which can then be used in `#[cfg(...)]` for conditional compilation.
|
||||
///
|
||||
/// All configs that can potentially be enabled should be unconditionally declared using
|
||||
/// [`Self::declare()`].
|
||||
pub fn enable(&mut self, cfg: impl AsRef<str>) {
|
||||
if self.enabled.insert(cfg.as_ref().to_owned()) {
|
||||
println!("cargo:rustc-cfg={}", cfg.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enable_all(&mut self, cfgs: &[impl AsRef<str>]) {
|
||||
for cfg in cfgs.iter() {
|
||||
self.enable(cfg.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
/// Declare a valid config for conditional compilation, without enabling it.
|
||||
///
|
||||
/// This enables rustc to check that the configs in `#[cfg(...)]` attributes are valid.
|
||||
pub fn declare(&mut self, cfg: impl AsRef<str>) {
|
||||
if self.declared.insert(cfg.as_ref().to_owned()) {
|
||||
println!("cargo:rustc-check-cfg=cfg({})", cfg.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn declare_all(&mut self, cfgs: &[impl AsRef<str>]) {
|
||||
for cfg in cfgs.iter() {
|
||||
self.declare(cfg.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set(&mut self, cfg: impl Into<String>, enable: bool) {
|
||||
let cfg = cfg.into();
|
||||
if enable {
|
||||
self.enable(cfg.clone());
|
||||
}
|
||||
self.declare(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets configs that describe the target platform.
|
||||
pub fn set_target_cfgs(cfgs: &mut CfgSet) {
|
||||
let target = env::var("TARGET").unwrap();
|
||||
|
||||
if target.starts_with("thumbv6m-") {
|
||||
cfgs.enable_all(&["cortex_m", "armv6m"]);
|
||||
} else if target.starts_with("thumbv7m-") {
|
||||
cfgs.enable_all(&["cortex_m", "armv7m"]);
|
||||
} else if target.starts_with("thumbv7em-") {
|
||||
cfgs.enable_all(&["cortex_m", "armv7m", "armv7em"]);
|
||||
} else if target.starts_with("thumbv8m.base") {
|
||||
cfgs.enable_all(&["cortex_m", "armv8m", "armv8m_base"]);
|
||||
} else if target.starts_with("thumbv8m.main") {
|
||||
cfgs.enable_all(&["cortex_m", "armv8m", "armv8m_main"]);
|
||||
}
|
||||
cfgs.declare_all(&[
|
||||
"cortex_m",
|
||||
"armv6m",
|
||||
"armv7m",
|
||||
"armv7em",
|
||||
"armv8m",
|
||||
"armv8m_base",
|
||||
"armv8m_main",
|
||||
]);
|
||||
|
||||
cfgs.set("has_fpu", target.ends_with("-eabihf"));
|
||||
}
|
|
@ -6,6 +6,7 @@ use core::fmt::{Debug, Display, LowerHex};
|
|||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ macro_rules! assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ macro_rules! assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -39,6 +42,7 @@ macro_rules! assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -50,6 +54,7 @@ macro_rules! debug_assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -61,6 +66,7 @@ macro_rules! debug_assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -72,6 +78,7 @@ macro_rules! debug_assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -83,20 +90,19 @@ macro_rules! todo {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::core::unreachable!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unreachable!($($x)*)
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
::core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
::defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -108,6 +114,7 @@ macro_rules! panic {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! trace {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -121,6 +128,7 @@ macro_rules! trace {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -134,6 +142,7 @@ macro_rules! debug {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! info {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -147,6 +156,7 @@ macro_rules! info {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! warn {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -160,6 +170,7 @@ macro_rules! warn {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! error {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -174,6 +185,7 @@ macro_rules! error {
|
|||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unwrap!($($x)*)
|
||||
|
@ -181,6 +193,7 @@ macro_rules! unwrap {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
match $crate::fmt::Try::into_result($arg) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#![cfg_attr(not(any(feature = "arch-std", feature = "arch-wasm")), no_std)]
|
||||
#![cfg_attr(feature = "nightly", feature(waker_getters))]
|
||||
#![allow(clippy::new_without_default)]
|
||||
#![doc = include_str!("../README.md")]
|
||||
#![warn(missing_docs)]
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use core::mem;
|
||||
use core::task::{RawWaker, RawWakerVTable, Waker};
|
||||
|
||||
use super::{wake_task, TaskHeader, TaskRef};
|
||||
|
@ -33,20 +32,32 @@ pub(crate) unsafe fn from_task(p: TaskRef) -> Waker {
|
|||
///
|
||||
/// Panics if the waker is not created by the Embassy executor.
|
||||
pub fn task_from_waker(waker: &Waker) -> TaskRef {
|
||||
// safety: OK because WakerHack has the same layout as Waker.
|
||||
// This is not really guaranteed because the structs are `repr(Rust)`, it is
|
||||
// indeed the case in the current implementation.
|
||||
// TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992
|
||||
let hack: &WakerHack = unsafe { mem::transmute(waker) };
|
||||
if hack.vtable != &VTABLE {
|
||||
let (vtable, data) = {
|
||||
#[cfg(not(feature = "nightly"))]
|
||||
{
|
||||
struct WakerHack {
|
||||
data: *const (),
|
||||
vtable: &'static RawWakerVTable,
|
||||
}
|
||||
|
||||
// safety: OK because WakerHack has the same layout as Waker.
|
||||
// This is not really guaranteed because the structs are `repr(Rust)`, it is
|
||||
// indeed the case in the current implementation.
|
||||
// TODO use waker_getters when stable. https://github.com/rust-lang/rust/issues/96992
|
||||
let hack: &WakerHack = unsafe { core::mem::transmute(waker) };
|
||||
(hack.vtable, hack.data)
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
{
|
||||
let raw_waker = waker.as_raw();
|
||||
(raw_waker.vtable(), raw_waker.data())
|
||||
}
|
||||
};
|
||||
|
||||
if vtable != &VTABLE {
|
||||
panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.")
|
||||
}
|
||||
|
||||
// safety: our wakers are always created with `TaskRef::as_ptr`
|
||||
unsafe { TaskRef::from_ptr(hack.data as *const TaskHeader) }
|
||||
}
|
||||
|
||||
struct WakerHack {
|
||||
data: *const (),
|
||||
vtable: &'static RawWakerVTable,
|
||||
unsafe { TaskRef::from_ptr(data as *const TaskHeader) }
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use core::fmt::{Debug, Display, LowerHex};
|
|||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ macro_rules! assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ macro_rules! assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -39,6 +42,7 @@ macro_rules! assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -50,6 +54,7 @@ macro_rules! debug_assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -61,6 +66,7 @@ macro_rules! debug_assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -72,6 +78,7 @@ macro_rules! debug_assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -83,20 +90,19 @@ macro_rules! todo {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::core::unreachable!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unreachable!($($x)*)
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
::core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
::defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -108,6 +114,7 @@ macro_rules! panic {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! trace {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -121,6 +128,7 @@ macro_rules! trace {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -134,6 +142,7 @@ macro_rules! debug {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! info {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -147,6 +156,7 @@ macro_rules! info {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! warn {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -160,6 +170,7 @@ macro_rules! warn {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! error {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -174,6 +185,7 @@ macro_rules! error {
|
|||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unwrap!($($x)*)
|
||||
|
@ -181,6 +193,7 @@ macro_rules! unwrap {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
match $crate::fmt::Try::into_result($arg) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "embassy-hal-internal"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "Internal implementation details for Embassy HALs. DO NOT USE DIRECTLY."
|
||||
|
|
|
@ -1,29 +1,7 @@
|
|||
use std::env;
|
||||
#[path = "./build_common.rs"]
|
||||
mod common;
|
||||
|
||||
fn main() {
|
||||
let target = env::var("TARGET").unwrap();
|
||||
|
||||
if target.starts_with("thumbv6m-") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv6m");
|
||||
} else if target.starts_with("thumbv7m-") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv7m");
|
||||
} else if target.starts_with("thumbv7em-") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv7m");
|
||||
println!("cargo:rustc-cfg=armv7em"); // (not currently used)
|
||||
} else if target.starts_with("thumbv8m.base") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv8m");
|
||||
println!("cargo:rustc-cfg=armv8m_base");
|
||||
} else if target.starts_with("thumbv8m.main") {
|
||||
println!("cargo:rustc-cfg=cortex_m");
|
||||
println!("cargo:rustc-cfg=armv8m");
|
||||
println!("cargo:rustc-cfg=armv8m_main");
|
||||
}
|
||||
|
||||
if target.ends_with("-eabihf") {
|
||||
println!("cargo:rustc-cfg=has_fpu");
|
||||
}
|
||||
let mut cfgs = common::CfgSet::new();
|
||||
common::set_target_cfgs(&mut cfgs);
|
||||
}
|
||||
|
|
94
embassy-hal-internal/build_common.rs
Normal file
94
embassy-hal-internal/build_common.rs
Normal file
|
@ -0,0 +1,94 @@
|
|||
// NOTE: this file is copy-pasted between several Embassy crates, because there is no
|
||||
// straightforward way to share this code:
|
||||
// - it cannot be placed into the root of the repo and linked from each build.rs using `#[path =
|
||||
// "../build_common.rs"]`, because `cargo publish` requires that all files published with a crate
|
||||
// reside in the crate's directory,
|
||||
// - it cannot be symlinked from `embassy-xxx/build_common.rs` to `../build_common.rs`, because
|
||||
// symlinks don't work on Windows.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::env;
|
||||
|
||||
/// Helper for emitting cargo instruction for enabling configs (`cargo:rustc-cfg=X`) and declaring
|
||||
/// them (`cargo:rust-check-cfg=cfg(X)`).
|
||||
#[derive(Debug)]
|
||||
pub struct CfgSet {
|
||||
enabled: HashSet<String>,
|
||||
declared: HashSet<String>,
|
||||
}
|
||||
|
||||
impl CfgSet {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
enabled: HashSet::new(),
|
||||
declared: HashSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Enable a config, which can then be used in `#[cfg(...)]` for conditional compilation.
|
||||
///
|
||||
/// All configs that can potentially be enabled should be unconditionally declared using
|
||||
/// [`Self::declare()`].
|
||||
pub fn enable(&mut self, cfg: impl AsRef<str>) {
|
||||
if self.enabled.insert(cfg.as_ref().to_owned()) {
|
||||
println!("cargo:rustc-cfg={}", cfg.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enable_all(&mut self, cfgs: &[impl AsRef<str>]) {
|
||||
for cfg in cfgs.iter() {
|
||||
self.enable(cfg.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
/// Declare a valid config for conditional compilation, without enabling it.
|
||||
///
|
||||
/// This enables rustc to check that the configs in `#[cfg(...)]` attributes are valid.
|
||||
pub fn declare(&mut self, cfg: impl AsRef<str>) {
|
||||
if self.declared.insert(cfg.as_ref().to_owned()) {
|
||||
println!("cargo:rustc-check-cfg=cfg({})", cfg.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn declare_all(&mut self, cfgs: &[impl AsRef<str>]) {
|
||||
for cfg in cfgs.iter() {
|
||||
self.declare(cfg.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set(&mut self, cfg: impl Into<String>, enable: bool) {
|
||||
let cfg = cfg.into();
|
||||
if enable {
|
||||
self.enable(cfg.clone());
|
||||
}
|
||||
self.declare(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets configs that describe the target platform.
|
||||
pub fn set_target_cfgs(cfgs: &mut CfgSet) {
|
||||
let target = env::var("TARGET").unwrap();
|
||||
|
||||
if target.starts_with("thumbv6m-") {
|
||||
cfgs.enable_all(&["cortex_m", "armv6m"]);
|
||||
} else if target.starts_with("thumbv7m-") {
|
||||
cfgs.enable_all(&["cortex_m", "armv7m"]);
|
||||
} else if target.starts_with("thumbv7em-") {
|
||||
cfgs.enable_all(&["cortex_m", "armv7m", "armv7em"]);
|
||||
} else if target.starts_with("thumbv8m.base") {
|
||||
cfgs.enable_all(&["cortex_m", "armv8m", "armv8m_base"]);
|
||||
} else if target.starts_with("thumbv8m.main") {
|
||||
cfgs.enable_all(&["cortex_m", "armv8m", "armv8m_main"]);
|
||||
}
|
||||
cfgs.declare_all(&[
|
||||
"cortex_m",
|
||||
"armv6m",
|
||||
"armv7m",
|
||||
"armv7em",
|
||||
"armv8m",
|
||||
"armv8m_base",
|
||||
"armv8m_main",
|
||||
]);
|
||||
|
||||
cfgs.set("has_fpu", target.ends_with("-eabihf"));
|
||||
}
|
|
@ -6,6 +6,7 @@ use core::fmt::{Debug, Display, LowerHex};
|
|||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ macro_rules! assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ macro_rules! assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -39,6 +42,7 @@ macro_rules! assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -50,6 +54,7 @@ macro_rules! debug_assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -61,6 +66,7 @@ macro_rules! debug_assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -72,6 +78,7 @@ macro_rules! debug_assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -83,20 +90,19 @@ macro_rules! todo {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::core::unreachable!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unreachable!($($x)*)
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
::core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
::defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -108,6 +114,7 @@ macro_rules! panic {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! trace {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -121,6 +128,7 @@ macro_rules! trace {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -134,6 +142,7 @@ macro_rules! debug {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! info {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -147,6 +156,7 @@ macro_rules! info {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! warn {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -160,6 +170,7 @@ macro_rules! warn {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! error {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -174,6 +185,7 @@ macro_rules! error {
|
|||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unwrap!($($x)*)
|
||||
|
@ -181,6 +193,7 @@ macro_rules! unwrap {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
match $crate::fmt::Try::into_result($arg) {
|
||||
|
|
|
@ -16,8 +16,8 @@ log = { version = "0.4", default-features = false, optional = true }
|
|||
embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
|
||||
embedded-hal-async = { version = "1.0" }
|
||||
embedded-hal-bus = { version = "0.1", features = ["async"] }
|
||||
embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" }
|
||||
embassy-time = { version = "0.3.0", path = "../embassy-time" }
|
||||
embassy-net-driver-channel = { version = "0.3.0", path = "../embassy-net-driver-channel" }
|
||||
embassy-time = { version = "0.3.2", path = "../embassy-time" }
|
||||
embassy-futures = { version = "0.1.0", path = "../embassy-futures" }
|
||||
bitfield = "0.14.0"
|
||||
|
||||
|
@ -29,7 +29,6 @@ critical-section = { version = "1.1.2", features = ["std"] }
|
|||
futures-test = "0.3.28"
|
||||
|
||||
[features]
|
||||
default = [ ]
|
||||
defmt = [ "dep:defmt", "embedded-hal-1/defmt-03" ]
|
||||
log = ["dep:log"]
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ APL can be used in [`intrinsic safety applications/explosion hazardous areas`](h
|
|||
|
||||
## Supported SPI modes
|
||||
|
||||
`ADIN1110` supports two SPI modes. `Generic` and [`OPEN Alliance 10BASE-T1x MAC-PHY serial interface`](https://opensig.org/download/document/OPEN_Alliance_10BASET1x_MAC-PHY_Serial_Interface_V1.1.pdf)
|
||||
`ADIN1110` supports two SPI modes. `Generic` and [`OPEN Alliance 10BASE-T1x MAC-PHY serial interface`](https://opensig.org/wp-content/uploads/2023/12/OPEN_Alliance_10BASET1x_MAC-PHY_Serial_Interface_V1.1.pdf)
|
||||
|
||||
Both modes support with and without additional CRC.
|
||||
Currently only `Generic` SPI with or without CRC is supported.
|
||||
|
|
|
@ -16,7 +16,7 @@ const CRC8X_TABLE: [u8; 256] = [
|
|||
0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3,
|
||||
];
|
||||
|
||||
/// Calculate the crc of a pease of data.
|
||||
/// Calculate the crc of a piece of data.
|
||||
pub fn crc8(data: &[u8]) -> u8 {
|
||||
data.iter().fold(0, |crc, &byte| CRC8X_TABLE[usize::from(byte ^ crc)])
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use core::fmt::{Debug, Display, LowerHex};
|
|||
#[cfg(all(feature = "defmt", feature = "log"))]
|
||||
compile_error!("You may not enable both `defmt` and `log` features.");
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ macro_rules! assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ macro_rules! assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -39,6 +42,7 @@ macro_rules! assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -50,6 +54,7 @@ macro_rules! debug_assert {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_eq {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -61,6 +66,7 @@ macro_rules! debug_assert_eq {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug_assert_ne {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -72,6 +78,7 @@ macro_rules! debug_assert_ne {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! todo {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -83,20 +90,19 @@ macro_rules! todo {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::core::unreachable!($($x)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
macro_rules! unreachable {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unreachable!($($x)*)
|
||||
{
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
::core::unreachable!($($x)*);
|
||||
#[cfg(feature = "defmt")]
|
||||
::defmt::unreachable!($($x)*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! panic {
|
||||
($($x:tt)*) => {
|
||||
{
|
||||
|
@ -108,6 +114,7 @@ macro_rules! panic {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! trace {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -121,6 +128,7 @@ macro_rules! trace {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! debug {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -134,6 +142,7 @@ macro_rules! debug {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! info {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -147,6 +156,7 @@ macro_rules! info {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! warn {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -160,6 +170,7 @@ macro_rules! warn {
|
|||
};
|
||||
}
|
||||
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! error {
|
||||
($s:literal $(, $x:expr)* $(,)?) => {
|
||||
{
|
||||
|
@ -174,6 +185,7 @@ macro_rules! error {
|
|||
}
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($($x:tt)*) => {
|
||||
::defmt::unwrap!($($x)*)
|
||||
|
@ -181,6 +193,7 @@ macro_rules! unwrap {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "defmt"))]
|
||||
#[collapse_debuginfo(yes)]
|
||||
macro_rules! unwrap {
|
||||
($arg:expr) => {
|
||||
match $crate::fmt::Try::into_result($arg) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue