mirror of
https://github.com/google/pebble.git
synced 2025-11-08 08:32:45 -05:00
Compare commits
478 Commits
3cd262063f
...
74b93756f3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74b93756f3 | ||
|
|
4051c5bb97 | ||
|
|
5b5d49cb49 | ||
|
|
f19ace2e3c | ||
|
|
3f343671ce | ||
|
|
ecfd50f991 | ||
|
|
718ea629a5 | ||
|
|
bb79879779 | ||
|
|
a33fc19e8e | ||
|
|
af088d08a6 | ||
|
|
7049285694 | ||
|
|
4f5fbed978 | ||
|
|
be5dc944b3 | ||
|
|
fed3c7b83f | ||
|
|
09c53ebd36 | ||
|
|
b778cd6794 | ||
|
|
8ee2a95771 | ||
|
|
7885833fe8 | ||
|
|
3bde9c1ab3 | ||
|
|
7499ab128b | ||
|
|
36c9aac1f5 | ||
|
|
39c1e7b34f | ||
|
|
159e6cc255 | ||
|
|
0098e27ba5 | ||
|
|
c1e8ef32bd | ||
|
|
d37fe946e1 | ||
|
|
a679c3d713 | ||
|
|
58d50a77e5 | ||
|
|
03c66ad51e | ||
|
|
0f74b405d0 | ||
|
|
445eb1471b | ||
|
|
c32466e61e | ||
|
|
523e6cf397 | ||
|
|
82ee3a22ea | ||
|
|
f6d5f8ce95 | ||
|
|
e5fbc9e67e | ||
|
|
76f3819b39 | ||
|
|
e38db99b9d | ||
|
|
762142cebc | ||
|
|
cb44bb9967 | ||
|
|
cceec5ae32 | ||
|
|
be54304b88 | ||
|
|
4be1d9c8ac | ||
|
|
58c22748cc | ||
|
|
b7297fd9f4 | ||
|
|
120c7e248c | ||
|
|
e53dc17016 | ||
|
|
7594b4c878 | ||
|
|
913fa41c99 | ||
|
|
f257b7ae1f | ||
|
|
994d10f5df | ||
|
|
4ba1278010 | ||
|
|
9485f1e908 | ||
|
|
79e6f0cf2f | ||
|
|
374b10c683 | ||
|
|
d09aca0a02 | ||
|
|
34b2a18fcc | ||
|
|
9077267ceb | ||
|
|
5cb061cff5 | ||
|
|
ccca8fddcd | ||
|
|
c477e689c9 | ||
|
|
53b74221f2 | ||
|
|
979061a875 | ||
|
|
0a909d7a50 | ||
|
|
b32d22a6d2 | ||
|
|
202215e86c | ||
|
|
6ba090d3ce | ||
|
|
f2b037375c | ||
|
|
a169a706b7 | ||
|
|
bcf5e6d9f9 | ||
|
|
aacf4a9ab6 | ||
|
|
eadb5ca422 | ||
|
|
9e89559322 | ||
|
|
aee29ca34b | ||
|
|
56b1584352 | ||
|
|
9bf2e4c8dc | ||
|
|
836341f13b | ||
|
|
85257fc5c4 | ||
|
|
da5daef528 | ||
|
|
f7e65496ba | ||
|
|
06296179d9 | ||
|
|
f14d9da22e | ||
|
|
55d1f98745 | ||
|
|
edb0a78b0a | ||
|
|
c2cf2fd848 | ||
|
|
56f907ed6b | ||
|
|
6fc8ed0772 | ||
|
|
88ce796b6c | ||
|
|
cd8520acbf | ||
|
|
9e6d15a209 | ||
|
|
848a68c241 | ||
|
|
faf96c3ee2 | ||
|
|
94240d33f2 | ||
|
|
ced5200233 | ||
|
|
9dc350a663 | ||
|
|
0666aa0089 | ||
|
|
608aac6e0b | ||
|
|
cbbaeba03c | ||
|
|
b8c84e077c | ||
|
|
47319ea499 | ||
|
|
1d3a78f7b6 | ||
|
|
5cb667ae61 | ||
|
|
9ecddce587 | ||
|
|
fc2f5a982e | ||
|
|
6dbbbee3e2 | ||
|
|
c5495ecbc5 | ||
|
|
927251a776 | ||
|
|
586db5b942 | ||
|
|
394c11d071 | ||
|
|
b33c3a748e | ||
|
|
acad6e8efa | ||
|
|
eddc390e76 | ||
|
|
16f151faa2 | ||
|
|
c29f9fee52 | ||
|
|
173bdadc3a | ||
|
|
93135f6c5a | ||
|
|
3faa3c0faf | ||
|
|
99187c5d4e | ||
|
|
fa22912737 | ||
|
|
466e7f7505 | ||
|
|
656ba98a40 | ||
|
|
2062536f26 | ||
|
|
c42dfbcdfc | ||
|
|
0a6167953f | ||
|
|
0423ca826f | ||
|
|
5d1081bc13 | ||
|
|
3d85a9cb3b | ||
|
|
0d9e35fad1 | ||
|
|
71e60e3b87 | ||
|
|
1732aa321b | ||
|
|
6590c67a88 | ||
|
|
e2cad1d2fb | ||
|
|
1ac3b3ccc6 | ||
|
|
d0a5f03b93 | ||
|
|
d9f57de352 | ||
|
|
cfea0fc3c2 | ||
|
|
0c55d530ac | ||
|
|
7d745d4c61 | ||
|
|
bc2c2393d7 | ||
|
|
5f98552305 | ||
|
|
fc797cd252 | ||
|
|
3b92b65db8 | ||
|
|
c7851d5745 | ||
|
|
1b10188be4 | ||
|
|
9f4d934ec4 | ||
|
|
a0222e963c | ||
|
|
a58187577d | ||
|
|
7420fcb525 | ||
|
|
d6ff98373d | ||
|
|
d56fb48114 | ||
|
|
47af5bd094 | ||
|
|
110e0fda31 | ||
|
|
866f4f003f | ||
|
|
5ed0a14ec3 | ||
|
|
f28754372d | ||
|
|
32e4e88d18 | ||
|
|
4329f3eeb6 | ||
|
|
8c57480b2a | ||
|
|
060d7cb58d | ||
|
|
67713b7888 | ||
|
|
e35b142f68 | ||
|
|
d4d8ed5147 | ||
|
|
cd127de7e0 | ||
|
|
d7c8734211 | ||
|
|
d527ad11b6 | ||
|
|
4cad9181a1 | ||
|
|
8ca8cffcc3 | ||
|
|
815e361d75 | ||
|
|
e3602b52fc | ||
|
|
ed1e3c836b | ||
|
|
ab86d94493 | ||
|
|
27cbe4bcba | ||
|
|
0887be2c39 | ||
|
|
7d8b2dc7aa | ||
|
|
dd02b29b2a | ||
|
|
33edf22381 | ||
|
|
fcfff639f7 | ||
|
|
52580daf82 | ||
|
|
d98fd94906 | ||
|
|
46910d0b3d | ||
|
|
8b9b5997fa | ||
|
|
dc15069898 | ||
|
|
3343c3a8b6 | ||
|
|
bd132b4003 | ||
|
|
0a17a4a67c | ||
|
|
3572d429b2 | ||
|
|
db1840c0f5 | ||
|
|
1e3f63fe26 | ||
|
|
b2075d3b2a | ||
|
|
24100e233b | ||
|
|
2e769148e9 | ||
|
|
92b055a0c4 | ||
|
|
f44e5e50e9 | ||
|
|
13de07fe70 | ||
|
|
fce4b36689 | ||
|
|
329160068e | ||
|
|
9af84e083f | ||
|
|
a9dd33cea2 | ||
|
|
0c55874b21 | ||
|
|
a967d8f275 | ||
|
|
651f82f9c5 | ||
|
|
b7b8abcff7 | ||
|
|
6fcb2ed60e | ||
|
|
3f55864a85 | ||
|
|
9cf1456fff | ||
|
|
76f2f9643f | ||
|
|
3d34684548 | ||
|
|
0f0c1cca12 | ||
|
|
ca40ee484d | ||
|
|
489a1d54cd | ||
|
|
c2e8d1d0ce | ||
|
|
d9ec8a3438 | ||
|
|
fa235e9c73 | ||
|
|
c2f7961747 | ||
|
|
9985f1fdf3 | ||
|
|
56f2f72c43 | ||
|
|
808be075ae | ||
|
|
77b62896d8 | ||
|
|
47c7c80798 | ||
|
|
65efdcd686 | ||
|
|
723223e7a9 | ||
|
|
7898b0c0ed | ||
|
|
d755d296fc | ||
|
|
607d0d33b8 | ||
|
|
1478a09825 | ||
|
|
13f4c1949e | ||
|
|
8db950eef8 | ||
|
|
2d73a5db2a | ||
|
|
448406972a | ||
|
|
1e36e9376c | ||
|
|
3103346331 | ||
|
|
14c0197dc2 | ||
|
|
04822e0ea5 | ||
|
|
0527df21d1 | ||
|
|
f8142aaa56 | ||
|
|
dff797266c | ||
|
|
df09a16db5 | ||
|
|
4e17c71160 | ||
|
|
efb437bff4 | ||
|
|
9a74f51086 | ||
|
|
2ca6621c38 | ||
|
|
7ee4164362 | ||
|
|
087fa58d43 | ||
|
|
a503372d8d | ||
|
|
f26b13d697 | ||
|
|
cb0ad69261 | ||
|
|
c01e9cf70d | ||
|
|
4806c06f10 | ||
|
|
a35061eaf8 | ||
|
|
d78f6df080 | ||
|
|
2437efdba9 | ||
|
|
57fd1766c0 | ||
|
|
1414ea00a4 | ||
|
|
c0f95d06d3 | ||
|
|
ef3b42207f | ||
|
|
1ecb14eb8a | ||
|
|
ee41f88dad | ||
|
|
ab2d0b338a | ||
|
|
ec3d12929e | ||
|
|
24dd728cf1 | ||
|
|
8d841c5e2e | ||
|
|
6e17914ae0 | ||
|
|
c592d79230 | ||
|
|
cb9fe3152f | ||
|
|
714282660f | ||
|
|
1e7f815c39 | ||
|
|
e63c8c0b83 | ||
|
|
cf9a5cb367 | ||
|
|
4ec73561f9 | ||
|
|
42ff2a4a3e | ||
|
|
9ab4efb8b8 | ||
|
|
9fd89172fc | ||
|
|
255d697f1b | ||
|
|
ae06af83ac | ||
|
|
294f626792 | ||
|
|
423a462ce0 | ||
|
|
191f0be9a7 | ||
|
|
8ce07c9151 | ||
|
|
fdc40c6e40 | ||
|
|
e291b6726e | ||
|
|
2efa9cc170 | ||
|
|
7128e60f76 | ||
|
|
d6faaacb44 | ||
|
|
10dee72f9e | ||
|
|
1fcda4287c | ||
|
|
d52c94a0ed | ||
|
|
69269d8bf1 | ||
|
|
7e0b951d8e | ||
|
|
07248ac67e | ||
|
|
01a349d9d4 | ||
|
|
28e0019973 | ||
|
|
bab9301a3a | ||
|
|
4816a8890b | ||
|
|
a57a2f6fea | ||
|
|
8513038ad2 | ||
|
|
30c49030d1 | ||
|
|
8ac24bd4f5 | ||
|
|
5351cd6f1c | ||
|
|
adb0257e93 | ||
|
|
91e869b7a5 | ||
|
|
11d05ba281 | ||
|
|
3c336ea7f5 | ||
|
|
0073a89149 | ||
|
|
6f28530f90 | ||
|
|
e7c5c587ae | ||
|
|
e479411f59 | ||
|
|
937ef82130 | ||
|
|
0adb006678 | ||
|
|
390d433bf8 | ||
|
|
22e6f64653 | ||
|
|
c4b4244b2d | ||
|
|
583bd2a005 | ||
|
|
5ea72eb54a | ||
|
|
f7145c9739 | ||
|
|
9a28b928ad | ||
|
|
bd5b200a81 | ||
|
|
0fe878c043 | ||
|
|
ecb5dae4ef | ||
|
|
f5e9b300f2 | ||
|
|
1f430457c1 | ||
|
|
cb8f7b7fc1 | ||
|
|
0de0ee0d68 | ||
|
|
874cd587c2 | ||
|
|
1c9c779192 | ||
|
|
0a46a061ff | ||
|
|
ed0bfa91da | ||
|
|
fa4eee1991 | ||
|
|
8231962ed3 | ||
|
|
fbdf1536ff | ||
|
|
a1f463ea99 | ||
|
|
e33cd4add1 | ||
|
|
11a46154bc | ||
|
|
0cf7d4d8e4 | ||
|
|
732a680ad8 | ||
|
|
16883e83c6 | ||
|
|
6c88d0de02 | ||
|
|
436c0cada7 | ||
|
|
f6321cfb9a | ||
|
|
1a6f00e08f | ||
|
|
42b59e79fb | ||
|
|
3237d40a97 | ||
|
|
ef22f1e4a9 | ||
|
|
6defdc6ebb | ||
|
|
5d8096f8f1 | ||
|
|
f9e2379cdb | ||
|
|
a6a27be9a5 | ||
|
|
0ad05d3c3d | ||
|
|
10bc03cd17 | ||
|
|
dc649bd184 | ||
|
|
f8d6aad3e7 | ||
|
|
a2e8bce4a9 | ||
|
|
4909e42a4f | ||
|
|
45c881e347 | ||
|
|
2e9824bf45 | ||
|
|
5c8207c8c2 | ||
|
|
e3c66a23c7 | ||
|
|
ebfec3118d | ||
|
|
924f309bff | ||
|
|
2f60d53f62 | ||
|
|
2b8a8dcfdd | ||
|
|
506c882fda | ||
|
|
a0b9ef4851 | ||
|
|
2d7ac814c6 | ||
|
|
621151ebd1 | ||
|
|
435ef6ba65 | ||
|
|
e39d9fc773 | ||
|
|
b92a7363d5 | ||
|
|
89894ab4f1 | ||
|
|
eef1e8dbd6 | ||
|
|
4824c55fed | ||
|
|
21884a76f2 | ||
|
|
deffe7f483 | ||
|
|
a989875686 | ||
|
|
1cceb1206d | ||
|
|
837f87c424 | ||
|
|
2a7d5ceaa4 | ||
|
|
e0d7a82844 | ||
|
|
82c69d2f5d | ||
|
|
c54407bb82 | ||
|
|
e3dd54fda9 | ||
|
|
74d9fc2ef5 | ||
|
|
5f8d2a47aa | ||
|
|
a29c01bf00 | ||
|
|
bd2c2ad356 | ||
|
|
9d85fb19ba | ||
|
|
15d5df83b8 | ||
|
|
a40b21060d | ||
|
|
e3c1fb279e | ||
|
|
f21d4da40f | ||
|
|
6d6b22b697 | ||
|
|
272237b048 | ||
|
|
9ac1fb003d | ||
|
|
0e66fca4ed | ||
|
|
d9cbe55fed | ||
|
|
6dd10b1640 | ||
|
|
2967f60ffc | ||
|
|
9d9edae49f | ||
|
|
81b2d104a6 | ||
|
|
726d92f563 | ||
|
|
d8ade6b665 | ||
|
|
ae61face91 | ||
|
|
9f095745da | ||
|
|
0b140893f9 | ||
|
|
d3175992ea | ||
|
|
27d14ba72a | ||
|
|
348660fb1e | ||
|
|
ee449fd875 | ||
|
|
e3df3055e2 | ||
|
|
5dfb79c189 | ||
|
|
4f43035df7 | ||
|
|
30232b4c27 | ||
|
|
f7cac0ad9b | ||
|
|
04ba22ffb9 | ||
|
|
888911aaa9 | ||
|
|
9c5fc488e0 | ||
|
|
4a26ea9f66 | ||
|
|
4011cdd2c3 | ||
|
|
71513f263b | ||
|
|
5489a4c0d3 | ||
|
|
0248c81c86 | ||
|
|
a40097521c | ||
|
|
53cdea8d3d | ||
|
|
e681b24ea3 | ||
|
|
3dc43a4c1b | ||
|
|
2e05d7addb | ||
|
|
0ab43a028e | ||
|
|
dc157413ef | ||
|
|
de2ef95804 | ||
|
|
5a7fdca2e4 | ||
|
|
4c1819019d | ||
|
|
7bccc39af7 | ||
|
|
6dd9f2a7ed | ||
|
|
fc4b5a3b02 | ||
|
|
0af48bf2c5 | ||
|
|
dc6250106b | ||
|
|
87e43e8978 | ||
|
|
06a79bb396 | ||
|
|
faec942996 | ||
|
|
7bd5bbfeb1 | ||
|
|
b0efa9eb1a | ||
|
|
da8071bdb5 | ||
|
|
1114914d33 | ||
|
|
2529de015f | ||
|
|
852098a92e | ||
|
|
85e2476bcf | ||
|
|
575b358aa5 | ||
|
|
bbcf3ec07d | ||
|
|
b8d261b2e0 | ||
|
|
05d09de90b | ||
|
|
0bef7743f6 | ||
|
|
17765dce27 | ||
|
|
4ed89321ff | ||
|
|
405717f0de | ||
|
|
e02cd968c2 | ||
|
|
d12fb4b380 | ||
|
|
49b0f1f668 | ||
|
|
916a84faca | ||
|
|
3e4d224e8b | ||
|
|
03349f2d2b | ||
|
|
9ef3483674 | ||
|
|
2df7d018dd | ||
|
|
395e6d3b22 | ||
|
|
2e283181ba | ||
|
|
daf0574d29 | ||
|
|
6d23cc16b3 | ||
|
|
a5ba1d6026 | ||
|
|
80421e092f | ||
|
|
572925d9fb | ||
|
|
2a9f359b51 | ||
|
|
d2e293116f | ||
|
|
643abbfcf3 | ||
|
|
b60d61e5e1 | ||
|
|
eb5cbb2f63 | ||
|
|
2a7756f365 | ||
|
|
21eca690fa | ||
|
|
d2219b299e | ||
|
|
605fe7756e | ||
|
|
4ed801eaf9 |
@@ -558,7 +558,7 @@ jerry_size_t jerry_object_to_string_to_utf8_char_buffer(const jerry_value_t obje
|
||||
return len;
|
||||
}
|
||||
|
||||
// FIXME: PBL-43551 Propery CESU-8 => UTF-8 conversion.
|
||||
// FIXME: PBL-43551 Property CESU-8 => UTF-8 conversion.
|
||||
jerry_size_t jerry_object_to_string_to_char_buffer(const jerry_value_t object,
|
||||
jerry_char_t *buffer_p,
|
||||
jerry_size_t buffer_size) {
|
||||
|
||||
@@ -160,7 +160,7 @@ static bool prv_get_resource(uint32_t resource_id, Resource *res) {
|
||||
if ((entry.resource_id != resource_id) ||
|
||||
(entry.length == 0)) {
|
||||
// empty resource
|
||||
printf("%s: Invalid resourcel for %d\n", __FILE__, resource_id);
|
||||
printf("%s: Invalid resource for %d\n", __FILE__, resource_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "resource/resource.h"
|
||||
|
||||
// transformed to int to avoid surpises between C->JS
|
||||
// transformed to int to avoid surprises between C->JS
|
||||
typedef int (*ResourceReadCb)(int offset, uint8_t *buf, int num_bytes);
|
||||
typedef int (*ResourceGetSizeCb)(void);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace std {
|
||||
}
|
||||
|
||||
/* This analyzer suffers from the major limitation that most of the mutexes in Pebble are globals,
|
||||
* so all symbols and MemRegions refering to the mutexes are invalidated every time an unknown
|
||||
* so all symbols and MemRegions referring to the mutexes are invalidated every time an unknown
|
||||
* function is called. This analyzer instead associates mutexes with the declaration of their
|
||||
* variables, which has the obvious limitation of not catching when mutexes are passed as
|
||||
* arguments (which fortunately never? happens in pebble).
|
||||
|
||||
@@ -191,11 +191,11 @@ This function affects subsequent calls to \ref rand() to produce a sequence of n
|
||||
`setlocale` can be used to:
|
||||
- set the app's locale to a specific locale: `setlocale(LC_ALL, "en_CA")`
|
||||
- set the app's locale to the system locale: `setlocale(LC_ALL, "")`
|
||||
- get the app's curent locale: `setlocale(LC_ALL, NULL)`
|
||||
- get the app's current locale: `setlocale(LC_ALL, NULL)`
|
||||
|
||||
\param category The category of routines for which to set the locale
|
||||
\param locale The ISO formatted locale to use, or "" for the system locale
|
||||
\return the locale after the change is applied, NULL on failure (e.g. unsuported category)
|
||||
\return the locale after the change is applied, NULL on failure (e.g. unsupported category)
|
||||
\note Currently, we only support two categories: LC_ALL and LC_TIME
|
||||
|
||||
@}
|
||||
@@ -421,7 +421,7 @@ original allocation or the new size into the newly allocated buffer.
|
||||
\return The destination buffer dest
|
||||
|
||||
\fn char *strncat(char *dest, const char *src, size_t n)
|
||||
\brief Concatenates up to n bytes from the string in src to the end of the string pointed by dest and null terminates dest. There should be no overlap of dest and src in memeory.
|
||||
\brief Concatenates up to n bytes from the string in src to the end of the string pointed by dest and null terminates dest. There should be no overlap of dest and src in memory.
|
||||
\param dest The destination buffer with enough space for src beyond the null character
|
||||
\param src The source string
|
||||
\param n The maximum number of bytes to copy
|
||||
|
||||
@@ -100,7 +100,7 @@ with the target address and data. The receiver performs the write and
|
||||
sends an acknowledgement with the address. If the sender doesn't receive
|
||||
an acknowledgement within some timeout, it re-sends the write command.
|
||||
Any number of write commands and acknowledgements can be in-flight
|
||||
simulatneously. If a write completes but the acknowledgement is lost in
|
||||
simultaneously. If a write completes but the acknowledgement is lost in
|
||||
transit, the sender can re-send the same write command and the receiver
|
||||
can naively overwrite the data without issue due to the idempotence of
|
||||
flash writes.
|
||||
@@ -149,7 +149,7 @@ Applications can choose to communicate with either best-effort datagram
|
||||
service (like PULSEv1), or reliable datagram service that guarantees
|
||||
in-order datagram delivery. Having the reliable transport available
|
||||
made it very easy to implement prompt commands over PULSEv2. And it was
|
||||
also suprisingly easy to implement a PULSEv2 transport for the Pebble
|
||||
also surprisingly easy to implement a PULSEv2 transport for the Pebble
|
||||
Protocol, which allows developers and test automation to interact with
|
||||
bigboards using libpebble2 and pebble-tool, exactly like they can with
|
||||
emulators and sealed watches connected to phones.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FreeRTOS lets us create tasks, which are independant threads of execution. We create a few ourselves, and more are created internally by FreeRTOS. We have pre-emption enabled in our FreeRTOS configuration, so we must be mindful of which other tasks are mucking with the same data. This document describes the tasks that exist in our system.
|
||||
FreeRTOS lets us create tasks, which are independent threads of execution. We create a few ourselves, and more are created internally by FreeRTOS. We have pre-emption enabled in our FreeRTOS configuration, so we must be mindful of which other tasks are mucking with the same data. This document describes the tasks that exist in our system.
|
||||
|
||||
FreeRTOS Tasks
|
||||
==============
|
||||
@@ -10,7 +10,7 @@ Timers that are registered using our timer infrastructure are executed on this t
|
||||
|
||||
"IDLE" - The idle task
|
||||
----------------------
|
||||
This is a special task used by the FreeRTOS scheduler. It's defined at it's own priority level which is at the lowest priority. If no other task is ready to run, either due to waiting on a semaphore or waiting using vTaskDelay (or something like that), the idle task is chosen to run instead.
|
||||
This is a special task used by the FreeRTOS scheduler. It's defined at its own priority level which is at the lowest priority. If no other task is ready to run, either due to waiting on a semaphore or waiting using vTaskDelay (or something like that), the idle task is chosen to run instead.
|
||||
|
||||
We have modified FreeRTOS such that if we're in the idle task, we enter a lower power mode, either sleep or stop. Stop mode is special in that peripheral clocks are shut down when we go into stop and are not automatically turned back on when we leave stop mode. This means we have to go through and turn them all back on. This is what the `register_stop_mode_resume_callback` function does. It allows individual drivers to register callbacks that are called when we leave stop from the idle thread. This comes with a caveat though. Since the idle thread only ever runs when there's nothing else to run, the scheduler assumes that there is always a task to run. This means that if the idle task is stopped or delayed for any reason, the scheduler will explode. Therefore you are not permitted to do operations that may stop the task's execution from within the resume callback.
|
||||
|
||||
@@ -34,4 +34,4 @@ This task is created for the currently running app. No task is created for the l
|
||||
Open Questions
|
||||
==============
|
||||
|
||||
Which tasks are allowed to manipulate the window state? What if the launcher wants to push a notification window at the same time as an app pushes it's own window?
|
||||
Which tasks are allowed to manipulate the window state? What if the launcher wants to push a notification window at the same time as an app pushes its own window?
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This script works around an issue in MacOS 10.9 (Mavericks) that causes
|
||||
# This script works around an issue in macOS 10.9 (Mavericks) that causes
|
||||
# it to go back to the original Apple USB FTDI drivers after a reboot.
|
||||
sudo kextunload /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBFTDI.kext
|
||||
sudo kextcache -system-prelinked-kernel
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This script works around an issue in MacOS 10.9 (Mavericks) that causes
|
||||
# This script works around an issue in macOS 10.9 (Mavericks) that causes
|
||||
# it to go back to the original Apple USB FTDI drivers after a reboot.
|
||||
sudo kextunload /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBFTDI.kext
|
||||
sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#define GPIO_Port_NULL ((GPIO_TypeDef *) 0)
|
||||
#define GPIO_Pin_NULL ((uint16_t)0x0000)
|
||||
|
||||
// This is generated in order to faciliate the check within the IRQ_MAP macro below
|
||||
// This is generated in order to facilitate the check within the IRQ_MAP macro below
|
||||
enum {
|
||||
#define IRQ_DEF(num, irq) IS_VALID_IRQ__##irq,
|
||||
#include "irq_stm32f7.def"
|
||||
|
||||
@@ -140,7 +140,7 @@ void display_init(void) {
|
||||
|
||||
// Work around an issue which some boards exhibit where the FPGA ring
|
||||
// oscillator can start up with higher harmonics, massively overclocking the
|
||||
// design and causing malfunction. When this occurrs, the draw-scene command
|
||||
// design and causing malfunction. When this occurs, the draw-scene command
|
||||
// will not work, asserting BUSY indefinitely but never updating the display.
|
||||
// Other commands such as display-on and display-off are less affected by the
|
||||
// overclocking, so the display can be turned on while the FPGA is in this
|
||||
|
||||
@@ -239,7 +239,7 @@ bool pmic_enable_battery_measure(void) {
|
||||
bool pmic_disable_battery_measure(void) {
|
||||
bool result = prv_set_mon_config_register(0);
|
||||
|
||||
// Releases the lock that was previously aquired in pmic_enable_battery_measure.
|
||||
// Releases the lock that was previously acquired in pmic_enable_battery_measure.
|
||||
prv_mon_config_unlock();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -138,7 +138,7 @@ void fw_copy_check_update_fw(void) {
|
||||
if (boot_bit_test(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS)) {
|
||||
dbgserial_putstr("Our previous firmware update failed, aborting update.");
|
||||
|
||||
// Pretend like the new firmware bit wasn't set afterall. We'll just run the
|
||||
// Pretend like the new firmware bit wasn't set after all. We'll just run the
|
||||
// previous code, whether that was normal firmware or the recovery firmware.
|
||||
boot_bit_clear(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS);
|
||||
boot_bit_clear(BOOT_BIT_NEW_FW_AVAILABLE);
|
||||
@@ -165,7 +165,7 @@ void fw_copy_check_update_fw(void) {
|
||||
break;
|
||||
case UPDATE_FW_ERROR_MICRO_FLASH_MANGLED:
|
||||
// We've broken our internal flash when trying to update our normal
|
||||
// firmware. Fall back immediately to the recovery firmare.
|
||||
// firmware. Fall back immediately to the recovery firmware.
|
||||
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
|
||||
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
|
||||
system_reset();
|
||||
|
||||
@@ -70,28 +70,28 @@ SECTIONS
|
||||
It is one task of the startup to copy the initial values from FLASH to RAM. */
|
||||
.data : {
|
||||
. = ALIGN(4);
|
||||
/* This is used by the startup in order to initialize the .data secion */
|
||||
/* This is used by the startup in order to initialize the .data section */
|
||||
__data_start = .;
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__data_end = .; /* This is used by the startup in order to initialize the .data secion */
|
||||
__data_end = .; /* This is used by the startup in order to initialize the .data section */
|
||||
} >RAM AT>FLASH
|
||||
__data_load_start = LOADADDR(.data);
|
||||
|
||||
/* This is the uninitialized data section */
|
||||
.bss (NOLOAD) : {
|
||||
. = ALIGN(4);
|
||||
__bss_start = .; /* This is used by the startup in order to initialize the .bss secion */
|
||||
__bss_start = .; /* This is used by the startup in order to initialize the .bss section */
|
||||
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end = .; /* This is used by the startup in order to initialize the .bss secion */
|
||||
__bss_end = .; /* This is used by the startup in order to initialize the .bss section */
|
||||
} >RAM
|
||||
|
||||
.stack (NOLOAD) : {
|
||||
|
||||
@@ -39,7 +39,7 @@ void delay_us(uint32_t us) {
|
||||
|
||||
void delay_ms(uint32_t millis) {
|
||||
// delay_us(millis*1000) is not used because a long delay could easily
|
||||
// overflow the veriable. Without the outer loop, a delay of even five
|
||||
// overflow the variable. Without the outer loop, a delay of even five
|
||||
// seconds would overflow.
|
||||
while (millis--) {
|
||||
delay_us(1000);
|
||||
|
||||
@@ -64,7 +64,7 @@ int ceil_log_two(uint32_t n);
|
||||
)
|
||||
|
||||
/**
|
||||
* Compute the next backoff interval using a bounded binary expoential backoff formula.
|
||||
* Compute the next backoff interval using a bounded binary exponential backoff formula.
|
||||
*
|
||||
* @param[in,out] attempt The number of retries performed so far. This count will be incremented
|
||||
* by the function.
|
||||
|
||||
@@ -53,7 +53,7 @@ __attribute__((__noreturn__)) void Default_Handler(void) {
|
||||
|
||||
// All these functions are weak references to the Default_Handler,
|
||||
// so if we define a handler in elsewhere in the firmware, these
|
||||
// will be overriden
|
||||
// will be overridden
|
||||
#define ALIAS(sym) __attribute__((__weak__, __alias__(sym)))
|
||||
ALIAS("Default_Handler") void NMI_Handler(void);
|
||||
ALIAS("Default_Handler") void HardFault_Handler(void);
|
||||
|
||||
@@ -97,7 +97,7 @@ def process_binary_header(self):
|
||||
sparse length encoding (see waftools/sparse_length_encoding.py).
|
||||
|
||||
The name of the array variable defaults to the source file name with all
|
||||
characters that are invaid C identifiers replaced with underscores. The name
|
||||
characters that are invalid C identifiers replaced with underscores. The name
|
||||
can be explicitly specified by setting the *array_name* parameter.
|
||||
|
||||
This method overrides the processing by
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
"""
|
||||
Support for converting linked targets to ihex, srec or binary files using
|
||||
objcopy. Use the 'objcopy' feature in conjuction with the 'cc' or 'cxx'
|
||||
objcopy. Use the 'objcopy' feature in conjunction with the 'cc' or 'cxx'
|
||||
feature. The 'objcopy' feature uses the following attributes:
|
||||
|
||||
objcopy_bfdname Target object format name (eg. ihex, srec, binary).
|
||||
|
||||
@@ -58,8 +58,8 @@ def encode(source):
|
||||
frequency.update(source)
|
||||
# most_common() doesn't define what happens if there's a tie in frequency. Let's always pick
|
||||
# the lowest value of that frequency to make the encoding predictable.
|
||||
occurences = frequency.most_common()
|
||||
escape = min(x[0] for x in occurences if x[1] == occurences[-1][1])
|
||||
occurrences = frequency.most_common()
|
||||
escape = min(x[0] for x in occurrences if x[1] == occurrences[-1][1])
|
||||
yield escape
|
||||
for b, g in groupby(source):
|
||||
if b == b'\0':
|
||||
|
||||
@@ -24,7 +24,7 @@ def options(opt):
|
||||
help='Which board to build for (robert_bb, robert_bb2, cutts_bb, robert_evt)')
|
||||
opt.add_option('--nowatchdog', action='store_true',
|
||||
help='Disable automatic reboots when watchdog fires')
|
||||
opt.add_option('--display_test', action='store_true', help='Enables the diplsay test loop')
|
||||
opt.add_option('--display_test', action='store_true', help='Enables the display test loop')
|
||||
|
||||
|
||||
def configure(conf):
|
||||
|
||||
@@ -143,7 +143,7 @@ void check_update_fw(void) {
|
||||
if (boot_bit_test(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS)) {
|
||||
dbgserial_putstr("Our previous firmware update failed, aborting update.");
|
||||
|
||||
// Pretend like the new firmware bit wasn't set afterall. We'll just run the
|
||||
// Pretend like the new firmware bit wasn't set after all. We'll just run the
|
||||
// previous code, whether that was normal firmware or the recovery firmware.
|
||||
boot_bit_clear(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS);
|
||||
boot_bit_clear(BOOT_BIT_NEW_FW_AVAILABLE);
|
||||
@@ -170,7 +170,7 @@ void check_update_fw(void) {
|
||||
break;
|
||||
case UPDATE_FW_ERROR_MICRO_FLASH_MANGLED:
|
||||
// We've broken our internal flash when trying to update our normal
|
||||
// firmware. Fall back immediately to the recovery firmare.
|
||||
// firmware. Fall back immediately to the recovery firmware.
|
||||
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
|
||||
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
|
||||
system_reset();
|
||||
|
||||
@@ -16,7 +16,7 @@ PROVIDE ( _Stack_Size = __Stack_Size ) ;
|
||||
|
||||
__Stack_Init = _estack - __Stack_Size ;
|
||||
|
||||
/*"PROVIDE" allows to easily override these values from an object file or the commmand line.*/
|
||||
/*"PROVIDE" allows to easily override these values from an object file or the command line.*/
|
||||
PROVIDE ( _Stack_Init = __Stack_Init ) ;
|
||||
|
||||
/*
|
||||
@@ -96,28 +96,28 @@ SECTIONS
|
||||
.data : AT ( _sidata )
|
||||
{
|
||||
. = ALIGN(4);
|
||||
/* This is used by the startup in order to initialize the .data secion */
|
||||
/* This is used by the startup in order to initialize the .data section */
|
||||
_sdata = .;
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* This is used by the startup in order to initialize the .data secion */
|
||||
_edata = .; /* This is used by the startup in order to initialize the .data section */
|
||||
} >RAM
|
||||
|
||||
/* This is the uninitialized data section */
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sbss = .; /* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* This is used by the startup in order to initialize the .bss section */
|
||||
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* This is used by the startup in order to initialize the .bss secion */
|
||||
_ebss = .; /* This is used by the startup in order to initialize the .bss section */
|
||||
} >RAM
|
||||
|
||||
.stack :
|
||||
|
||||
@@ -41,7 +41,7 @@ void NOINLINE delay_us(uint32_t us) {
|
||||
|
||||
void delay_ms(uint32_t millis) {
|
||||
// delay_us(millis*1000) is not used because a long delay could easily
|
||||
// overflow the veriable. Without the outer loop, a delay of even five
|
||||
// overflow the variable. Without the outer loop, a delay of even five
|
||||
// seconds would overflow.
|
||||
while (millis--) {
|
||||
delay_us(1000);
|
||||
|
||||
@@ -85,7 +85,7 @@ def process_binary_header(self):
|
||||
file is treated as a raw binary file.
|
||||
|
||||
The name of the array variable defaults to the source file name with all
|
||||
characters that are invaid C identifiers replaced with underscores. The name
|
||||
characters that are invalid C identifiers replaced with underscores. The name
|
||||
can be explicitly specified by setting the *array_name* parameter.
|
||||
|
||||
This method overrides the processing by
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
"""
|
||||
Support for converting linked targets to ihex, srec or binary files using
|
||||
objcopy. Use the 'objcopy' feature in conjuction with the 'cc' or 'cxx'
|
||||
objcopy. Use the 'objcopy' feature in conjunction with the 'cc' or 'cxx'
|
||||
feature. The 'objcopy' feature uses the following attributes:
|
||||
|
||||
objcopy_bfdname Target object format name (eg. ihex, srec, binary).
|
||||
|
||||
@@ -171,7 +171,7 @@ void display_power_disable(void) {
|
||||
|
||||
//!
|
||||
//! Write a single byte synchronously to the display. Use this
|
||||
//! sparingly, as it will tie up the micro duing the write.
|
||||
//! sparingly, as it will tie up the micro during the write.
|
||||
//!
|
||||
void display_write_byte(uint8_t d) {
|
||||
// Block until the tx buffer is empty
|
||||
|
||||
@@ -224,7 +224,7 @@ void display_init(void) {
|
||||
|
||||
// Work around an issue which some boards exhibit where the FPGA ring
|
||||
// oscillator can start up with higher harmonics, massively overclocking the
|
||||
// design and causing malfunction. When this occurrs, the draw-scene command
|
||||
// design and causing malfunction. When this occurs, the draw-scene command
|
||||
// will not work, asserting BUSY indefinitely but never updating the display.
|
||||
// Other commands such as display-on and display-off are less affected by the
|
||||
// overclocking, so the display can be turned on while the FPGA is in this
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "drivers/flash.h"
|
||||
|
||||
//! An address in the flash address spac
|
||||
//! An address in the flash address space
|
||||
typedef uint32_t FlashAddress;
|
||||
|
||||
//! This is the memory mapped region that's mapped to the parallel flash.
|
||||
@@ -45,10 +45,10 @@ typedef enum S29VSCommand {
|
||||
} S29VSCommand;
|
||||
|
||||
//! Arguments to the S29VSCommand_EraseSetup command
|
||||
typedef enum S29VSCommandEraseAguments {
|
||||
S29VSCommandEraseAguments_ChipErase = 0x10,
|
||||
S29VSCommandEraseAguments_SectorErase = 0x30
|
||||
} S29VSCommandEraseAguments;
|
||||
typedef enum S29VSCommandEraseArguments {
|
||||
S29VSCommandEraseArguments_ChipErase = 0x10,
|
||||
S29VSCommandEraseArguments_SectorErase = 0x30
|
||||
} S29VSCommandEraseArguments;
|
||||
|
||||
//! The bitset stored in the status register, see flash_s29vs_read_status_register
|
||||
typedef enum S29VSStatusBit {
|
||||
|
||||
@@ -144,7 +144,7 @@ bool pmic_init(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If not written to whithin 5 seconds of power-on the PMIC will shut down.
|
||||
// If not written to within 5 seconds of power-on the PMIC will shut down.
|
||||
//i2c_write_register(I2C_DEVICE_MAX14690, MAX14690_ADDR, PmicRegisters_HAND_SHK, 0x01);
|
||||
|
||||
// Power up 3.2V rail
|
||||
@@ -261,7 +261,7 @@ bool pmic_enable_battery_measure(void) {
|
||||
bool pmic_disable_battery_measure(void) {
|
||||
bool result = prv_set_mon_config_register(0);
|
||||
|
||||
// Releases the lock that was previously aquired in pmic_enable_battery_measure.
|
||||
// Releases the lock that was previously acquired in pmic_enable_battery_measure.
|
||||
prv_mon_config_unlock();
|
||||
|
||||
return result;
|
||||
@@ -327,7 +327,7 @@ static bool prv_is_alive(void) {
|
||||
return true;
|
||||
} else {
|
||||
PBL_LOG(LOG_LEVEL_DEBUG,
|
||||
"Error: read max14690 whomai byte 0x%x, expecting 0x%x", val, 0x01);
|
||||
"Error: read max14690 whoami byte 0x%x, expecting 0x%x", val, 0x01);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
#define FLASH_REGION_SYSTEM_RESOURCES_BEGIN 0x380000
|
||||
#define FLASH_REGION_SYSTEM_RESOURCES_END 0x400000 // 512k
|
||||
|
||||
// FIXME: The addresses below here are hacky work arounds and hopefully not the final place
|
||||
// FIXME: The addresses below here are hacky workarounds and hopefully not the final place
|
||||
// for these things. Hopefully many of them can move to the filesystem. Everything above here
|
||||
// should be pretty stable.
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ void check_update_fw(void) {
|
||||
if (boot_bit_test(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS)) {
|
||||
dbgserial_putstr("Our previous firmware update failed, aborting update.");
|
||||
|
||||
// Pretend like the new firmware bit wasn't set afterall. We'll just run the
|
||||
// Pretend like the new firmware bit wasn't set after all. We'll just run the
|
||||
// previous code, whether that was normal firmware or the recovery firmware.
|
||||
boot_bit_clear(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS);
|
||||
boot_bit_clear(BOOT_BIT_NEW_FW_AVAILABLE);
|
||||
@@ -156,7 +156,7 @@ void check_update_fw(void) {
|
||||
break;
|
||||
case UPDATE_FW_ERROR_MICRO_FLASH_MANGLED:
|
||||
// We've broken our internal flash when trying to update our normal
|
||||
// firmware. Fall back immediately to the recovery firmare.
|
||||
// firmware. Fall back immediately to the recovery firmware.
|
||||
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
|
||||
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
|
||||
system_reset();
|
||||
|
||||
@@ -16,7 +16,7 @@ PROVIDE ( _Stack_Size = __Stack_Size ) ;
|
||||
|
||||
__Stack_Init = _estack - __Stack_Size ;
|
||||
|
||||
/*"PROVIDE" allows to easily override these values from an object file or the commmand line.*/
|
||||
/*"PROVIDE" allows to easily override these values from an object file or the command line.*/
|
||||
PROVIDE ( _Stack_Init = __Stack_Init ) ;
|
||||
|
||||
/*
|
||||
@@ -96,28 +96,28 @@ SECTIONS
|
||||
.data : AT ( _sidata )
|
||||
{
|
||||
. = ALIGN(4);
|
||||
/* This is used by the startup in order to initialize the .data secion */
|
||||
/* This is used by the startup in order to initialize the .data section */
|
||||
_sdata = .;
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* This is used by the startup in order to initialize the .data secion */
|
||||
_edata = .; /* This is used by the startup in order to initialize the .data section */
|
||||
} >RAM
|
||||
|
||||
/* This is the uninitialized data section */
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sbss = .; /* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* This is used by the startup in order to initialize the .bss section */
|
||||
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* This is used by the startup in order to initialize the .bss secion */
|
||||
_ebss = .; /* This is used by the startup in order to initialize the .bss section */
|
||||
} >RAM
|
||||
|
||||
.stack :
|
||||
|
||||
@@ -36,7 +36,7 @@ void delay_us(uint32_t us) {
|
||||
|
||||
void delay_ms(uint32_t millis) {
|
||||
// delay_us(millis*1000) is not used because a long delay could easily
|
||||
// overflow the veriable. Without the outer loop, a delay of even five
|
||||
// overflow the variable. Without the outer loop, a delay of even five
|
||||
// seconds would overflow.
|
||||
while (millis--) {
|
||||
delay_us(1000);
|
||||
|
||||
@@ -79,7 +79,7 @@ const char *bool_to_str(bool b);
|
||||
bool convert_bt_addr_hex_str_to_bd_addr(const char *hex_str, uint8_t *bd_addr, const unsigned int bd_addr_size);
|
||||
|
||||
/**
|
||||
* Compute the next backoff interval using a bounded binary expoential backoff formula.
|
||||
* Compute the next backoff interval using a bounded binary exponential backoff formula.
|
||||
*
|
||||
* @param[in,out] attempt The number of retries performed so far. This count will be incremented by
|
||||
* the function.
|
||||
|
||||
@@ -84,7 +84,7 @@ def process_binary_header(self):
|
||||
file is treated as a raw binary file.
|
||||
|
||||
The name of the array variable defaults to the source file name with all
|
||||
characters that are invaid C identifiers replaced with underscores. The name
|
||||
characters that are invalid C identifiers replaced with underscores. The name
|
||||
can be explicitly specified by setting the *array_name* parameter.
|
||||
|
||||
This method overrides the processing by
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
"""
|
||||
Support for converting linked targets to ihex, srec or binary files using
|
||||
objcopy. Use the 'objcopy' feature in conjuction with the 'cc' or 'cxx'
|
||||
objcopy. Use the 'objcopy' feature in conjunction with the 'cc' or 'cxx'
|
||||
feature. The 'objcopy' feature uses the following attributes:
|
||||
|
||||
objcopy_bfdname Target object format name (eg. ihex, srec, binary).
|
||||
|
||||
@@ -182,7 +182,7 @@ void check_update_fw(void) {
|
||||
if (boot_bit_test(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS)) {
|
||||
dbgserial_putstr("Our previous firmware update failed, aborting update.");
|
||||
|
||||
// Pretend like the new firmware bit wasn't set afterall. We'll just run the
|
||||
// Pretend like the new firmware bit wasn't set after all. We'll just run the
|
||||
// previous code, whether that was normal firmware or the recovery firmware.
|
||||
boot_bit_clear(BOOT_BIT_NEW_FW_UPDATE_IN_PROGRESS);
|
||||
boot_bit_clear(BOOT_BIT_NEW_FW_AVAILABLE);
|
||||
@@ -209,7 +209,7 @@ void check_update_fw(void) {
|
||||
break;
|
||||
case UPDATE_FW_ERROR_MICRO_FLASH_MANGLED:
|
||||
// We've broken our internal flash when trying to update our normal
|
||||
// firmware. Fall back immediately to the recovery firmare.
|
||||
// firmware. Fall back immediately to the recovery firmware.
|
||||
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_ONE);
|
||||
boot_bit_set(BOOT_BIT_FW_START_FAIL_STRIKE_TWO);
|
||||
system_reset();
|
||||
|
||||
@@ -162,14 +162,14 @@ SECTIONS
|
||||
It is one task of the startup to copy the initial values from FLASH to RAM. */
|
||||
.data : {
|
||||
. = ALIGN(4);
|
||||
/* This is used by the startup in order to initialize the .data secion */
|
||||
/* This is used by the startup in order to initialize the .data section */
|
||||
__data_start = .;
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__data_end = .; /* This is used by the startup in order to initialize the .data secion */
|
||||
__data_end = .; /* This is used by the startup in order to initialize the .data section */
|
||||
} >RAM AT>FLASH
|
||||
__data_load_start = LOADADDR(.data);
|
||||
|
||||
@@ -177,14 +177,14 @@ SECTIONS
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start = .; /* This is used by the startup in order to initialize the .bss secion */
|
||||
__bss_start = .; /* This is used by the startup in order to initialize the .bss section */
|
||||
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end = .; /* This is used by the startup in order to initialize the .bss secion */
|
||||
__bss_end = .; /* This is used by the startup in order to initialize the .bss section */
|
||||
} >RAM
|
||||
|
||||
.stack (NOLOAD) :
|
||||
|
||||
@@ -41,7 +41,7 @@ void NOINLINE delay_us(uint32_t us) {
|
||||
|
||||
void delay_ms(uint32_t millis) {
|
||||
// delay_us(millis*1000) is not used because a long delay could easily
|
||||
// overflow the veriable. Without the outer loop, a delay of even five
|
||||
// overflow the variable. Without the outer loop, a delay of even five
|
||||
// seconds would overflow.
|
||||
while (millis--) {
|
||||
delay_us(1000);
|
||||
|
||||
@@ -85,7 +85,7 @@ def process_binary_header(self):
|
||||
file is treated as a raw binary file.
|
||||
|
||||
The name of the array variable defaults to the source file name with all
|
||||
characters that are invaid C identifiers replaced with underscores. The name
|
||||
characters that are invalid C identifiers replaced with underscores. The name
|
||||
can be explicitly specified by setting the *array_name* parameter.
|
||||
|
||||
This method overrides the processing by
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
"""
|
||||
Support for converting linked targets to ihex, srec or binary files using
|
||||
objcopy. Use the 'objcopy' feature in conjuction with the 'cc' or 'cxx'
|
||||
objcopy. Use the 'objcopy' feature in conjunction with the 'cc' or 'cxx'
|
||||
feature. The 'objcopy' feature uses the following attributes:
|
||||
|
||||
objcopy_bfdname Target object format name (eg. ihex, srec, binary).
|
||||
|
||||
@@ -140,7 +140,12 @@ def has_touch(ctx):
|
||||
|
||||
@conf
|
||||
def get_hrm(ctx):
|
||||
return None
|
||||
if is_robert(ctx):
|
||||
return "AS7000"
|
||||
elif is_silk(ctx):
|
||||
return "AS7000"
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
@conf
|
||||
|
||||
@@ -59,28 +59,28 @@ SECTIONS
|
||||
It is one task of the startup to copy the initial values from FLASH to RAM. */
|
||||
.data : {
|
||||
. = ALIGN(4);
|
||||
/* This is used by the startup in order to initialize the .data secion */
|
||||
/* This is used by the startup in order to initialize the .data section */
|
||||
__data_start = .;
|
||||
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
__data_end = .; /* This is used by the startup in order to initialize the .data secion */
|
||||
__data_end = .; /* This is used by the startup in order to initialize the .data section */
|
||||
} >RAM
|
||||
__data_load_start = LOADADDR(.data);
|
||||
|
||||
/* This is the uninitialized data section */
|
||||
.bss (NOLOAD) : {
|
||||
. = ALIGN(4);
|
||||
__bss_start = .; /* This is used by the startup in order to initialize the .bss secion */
|
||||
__bss_start = .; /* This is used by the startup in order to initialize the .bss section */
|
||||
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end = .; /* This is used by the startup in order to initialize the .bss secion */
|
||||
__bss_end = .; /* This is used by the startup in order to initialize the .bss section */
|
||||
} >RAM
|
||||
|
||||
.stack (NOLOAD) : {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
"""
|
||||
Support for converting linked targets to ihex, srec or binary files using
|
||||
objcopy. Use the 'objcopy' feature in conjuction with the 'cc' or 'cxx'
|
||||
objcopy. Use the 'objcopy' feature in conjunction with the 'cc' or 'cxx'
|
||||
feature. The 'objcopy' feature uses the following attributes:
|
||||
|
||||
objcopy_bfdname Target object format name (eg. ihex, srec, binary).
|
||||
|
||||
@@ -30,7 +30,7 @@ class FTDISerialWireDebug(object):
|
||||
self._ftdi = None
|
||||
raise
|
||||
|
||||
# get the FTDI FIFO size and increase the chuncksize to match
|
||||
# get the FTDI FIFO size and increase the chunksize to match
|
||||
self._ftdi_fifo_size = min(self._ftdi.fifo_sizes)
|
||||
self._ftdi.write_data_set_chunksize(self._ftdi_fifo_size)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ from ..util import stm32_crc
|
||||
|
||||
class PebbleFirmwareBinaryInfo(object):
|
||||
V1_STRUCT_VERSION = 1
|
||||
V1_STRUCT_DEFINTION = [
|
||||
V1_STRUCT_DEFINITION = [
|
||||
('20s', 'build_id'),
|
||||
('L', 'version_timestamp'),
|
||||
('32s', 'version_tag'),
|
||||
@@ -72,7 +72,7 @@ class PebbleFirmwareBinaryInfo(object):
|
||||
|
||||
def _get_footer_struct(self):
|
||||
fmt = '<' + reduce(lambda s, t: s + t[0],
|
||||
PebbleFirmwareBinaryInfo.V1_STRUCT_DEFINTION, '')
|
||||
PebbleFirmwareBinaryInfo.V1_STRUCT_DEFINITION, '')
|
||||
return struct.Struct(fmt)
|
||||
|
||||
def _get_footer_data_from_bin(self, path):
|
||||
@@ -83,7 +83,7 @@ class PebbleFirmwareBinaryInfo(object):
|
||||
return footer_data
|
||||
|
||||
def _parse_footer_data(self, footer_data):
|
||||
z = zip(PebbleFirmwareBinaryInfo.V1_STRUCT_DEFINTION,
|
||||
z = zip(PebbleFirmwareBinaryInfo.V1_STRUCT_DEFINITION,
|
||||
self.struct.unpack(footer_data))
|
||||
return {entry[1]: data for entry, data in z}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class EraseCommand(object):
|
||||
if unpacked.address != self.address or unpacked.length != self.length:
|
||||
raise exceptions.ResponseParseError(
|
||||
'Response does not match command: '
|
||||
'address=%#.08x legnth=%d (expected %#.08x, %d)' % (
|
||||
'address=%#.08x length=%d (expected %#.08x, %d)' % (
|
||||
unpacked.address, unpacked.length, self.address,
|
||||
self.length))
|
||||
return unpacked
|
||||
@@ -113,7 +113,7 @@ class CrcCommand(object):
|
||||
if unpacked.address != self.address or unpacked.length != self.length:
|
||||
raise exceptions.ResponseParseError(
|
||||
'Response does not match command: '
|
||||
'address=%#.08x legnth=%d (expected %#.08x, %d)' % (
|
||||
'address=%#.08x length=%d (expected %#.08x, %d)' % (
|
||||
unpacked.address, unpacked.length, self.address,
|
||||
self.length))
|
||||
return unpacked
|
||||
|
||||
@@ -92,7 +92,7 @@ class PebbleCommander(object):
|
||||
`PebbleCommander` as the first argument, and the rest of the argument strings
|
||||
as subsequent arguments. For errors, `fn` should throw an exception.
|
||||
|
||||
# TODO: Probably make the return something structured instead of stringly typed.
|
||||
# TODO: Probably make the return something structured instead of strongly typed.
|
||||
"""
|
||||
def decorator(fn):
|
||||
# Story time:
|
||||
@@ -151,7 +151,7 @@ class PebbleCommander(object):
|
||||
|
||||
def send_prompt_command(self, cmd):
|
||||
""" Send a prompt command string.
|
||||
Unfortunately this is indeed stringly typed, a better solution is necessary.
|
||||
Unfortunately this is indeed strongly typed, a better solution is necessary.
|
||||
"""
|
||||
return self.connection.prompt.command_and_response(cmd)
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ def dehash_str(hashed_info, lookup_dict):
|
||||
if formatted_string == hashed_info:
|
||||
formatted_string = lookup_dict.get(str(int(match.group('hash_key'), 16)), hashed_info)
|
||||
|
||||
# For each argument, substitute a C-style format specififier in the string
|
||||
# For each argument, substitute a C-style format specifier in the string
|
||||
for arg in parse_args(match.group('arg_list')):
|
||||
formatted_string = FORMAT_TAG_PATTERN.sub(arg, formatted_string, 1)
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ def test_parse_args():
|
||||
"""
|
||||
Test for parse_args()
|
||||
"""
|
||||
# No `` delimted strings
|
||||
# No `` delimited strings
|
||||
assert ["foo", "bar", "baz"] == parse_args("foo bar baz")
|
||||
|
||||
# `` delimited strings
|
||||
|
||||
@@ -114,7 +114,7 @@ class Interface(object):
|
||||
return socket
|
||||
|
||||
def unregister_socket(self, protocol):
|
||||
'''Used by InterfaceSocket objets to unregister themselves when
|
||||
'''Used by InterfaceSocket objects to unregister themselves when
|
||||
closing.
|
||||
'''
|
||||
try:
|
||||
|
||||
@@ -11,4 +11,4 @@ This archive contains v1.3 firmware for the Pebble E-Paper Watch.
|
||||
- 2v5 I2C driver bugfixes.
|
||||
- iPhone ACP stability improvements.
|
||||
- Text rendering performance improvements.
|
||||
- Support for entering shippiing-mode (standby) via a Bluetooth command.
|
||||
- Support for entering shipping-mode (standby) via a Bluetooth command.
|
||||
|
||||
@@ -30,7 +30,7 @@ This archive contains the EV2-4 software for the Pebble E-Paper Watch.
|
||||
included in the directory. For more information, please refer to
|
||||
the 'Flash imaging tools' section.
|
||||
- docs/spi_flash_imaging.txt: A document describing the protocol
|
||||
used to load load data onto Pebble's SPI flash via
|
||||
used to load data onto Pebble's SPI flash via
|
||||
the Serial UART
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ What's New
|
||||
* Improved Notification UI
|
||||
- Allows multiple notifications to be viewed if they arrive within a short time frame
|
||||
* Improved Set Time UI
|
||||
* Added the option of showing your current speed (as oppossed to your pace) in the RunKeeper application.
|
||||
* Added the option of showing your current speed (as opposed to your pace) in the RunKeeper application.
|
||||
* Swapped next and previous track buttons in the music application.
|
||||
* Added the Simplicity watchface.
|
||||
* Removed the Fuzzy Time watchface (it is available through the watchapp library).
|
||||
|
||||
@@ -17,7 +17,7 @@ device is started.
|
||||
|
||||
Once the firmware has loaded, a new screen will appear with a small
|
||||
picture of a watch and the text "Please Connect to Phone". Please note
|
||||
that the watch will not respond respond to button inputs while this
|
||||
that the watch will not respond to button inputs while this
|
||||
screen is being displayed.
|
||||
|
||||
Please contact ajw@getpebble.com with any questions.
|
||||
|
||||
@@ -76,7 +76,7 @@ echo "${README_TEXT}" > ${OUT_DIR}/README.txt
|
||||
# Create the requirements.txt file
|
||||
echo "${REQUIREMENTS_TEXT}" > ${OUT_DIR}/requirements.txt
|
||||
|
||||
# Copy the scripts we're interested into the ouput directory
|
||||
# Copy the scripts we're interested into the output directory
|
||||
mkdir -p ${OUT_DIR}/scripts
|
||||
cp tools/hdlc.py ${OUT_DIR}/scripts/
|
||||
cp tools/binutils.py ${OUT_DIR}/scripts/
|
||||
|
||||
@@ -79,7 +79,7 @@ echo "${README_TEXT}" > ${OUT_DIR}/README.txt
|
||||
# Create the requirements.txt file
|
||||
echo "${REQUIREMENTS_TEXT}" > ${OUT_DIR}/requirements.txt
|
||||
|
||||
# Copy the scripts we're interested into the ouput directory
|
||||
# Copy the scripts we're interested into the output directory
|
||||
mkdir -p ${OUT_DIR}/scripts
|
||||
cp tools/hdlc.py ${OUT_DIR}/scripts/
|
||||
cp tools/binutils.py ${OUT_DIR}/scripts/
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -1041,7 +1041,7 @@
|
||||
{
|
||||
"type": "pdc",
|
||||
"name": "DAY_SEPARATOR_SMALL",
|
||||
"file": "normal/base/images/Pebble_50x50_Day_seperator.svg"
|
||||
"file": "normal/base/images/Pebble_50x50_Day_separator.svg"
|
||||
},
|
||||
{
|
||||
"type": "pdc",
|
||||
|
||||
@@ -351,7 +351,7 @@
|
||||
if (this._getNextMessageType() !== "object") {
|
||||
// This is no longer our highest priority outgoing message.
|
||||
// Send that message instead, and this message will be left in the queue
|
||||
// andrestarted when appropriate.
|
||||
// and restarted when appropriate.
|
||||
this._resetCurrent();
|
||||
this._sendNext();
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Template vars injected by projess_js.py:
|
||||
// Template vars injected by process_js.py:
|
||||
|
||||
// boolean
|
||||
const isSandbox = ${IS_SANDBOX};
|
||||
|
||||
@@ -296,7 +296,7 @@ def _get_entry_point(ctx, js_type, waf_js_entry_point):
|
||||
def pbl_bundle(self, *k, **kw):
|
||||
"""
|
||||
This method is bound to the build context and is called by specifying `bld.pbl_bundle`. We
|
||||
set the custome features `js` and `bundle` to run when this method is invoked.
|
||||
set the custom features `js` and `bundle` to run when this method is invoked.
|
||||
:param self: the BuildContext object
|
||||
:param k: none expected
|
||||
:param kw:
|
||||
|
||||
@@ -35,7 +35,7 @@ def _generate_sdk_waf(ctx):
|
||||
for tool in sdk_waftools + shared_waftools:
|
||||
path = ctx.path.parent.find_node(tool)
|
||||
if path is None:
|
||||
ctx.fatal("Trying to bundle non existent resource in pb-waf ({})".format(tool))
|
||||
ctx.fatal("Trying to bundle nonexistent resource in pb-waf ({})".format(tool))
|
||||
pebble_waf_tools.append(path)
|
||||
|
||||
# We cannot run this as a sub-wscript because we use a specific vendor-provided
|
||||
|
||||
@@ -169,7 +169,7 @@ void handle_init(void) {
|
||||
|
||||
text_layer_set_text(text_layer, "? ? ?");
|
||||
|
||||
// Subscribe to mesages published by the worker
|
||||
// Subscribe to messages published by the worker
|
||||
app_worker_message_subscribe(steps_event_handler);
|
||||
|
||||
// Subscribe to second ticks
|
||||
|
||||
@@ -367,7 +367,7 @@ static void window_load(Window *window) {
|
||||
|
||||
layer_add_child(window_layer, menu_layer_get_layer(s_menu_layer));
|
||||
|
||||
// Start scanning. Advertisments will be delivered in the callback.
|
||||
// Start scanning. Advertisements will be delivered in the callback.
|
||||
toggle_scan();
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ static Animation *prv_create_custom_animation(void) {
|
||||
|
||||
|
||||
static void click_handler(ClickRecognizerRef recognizer, Window *window) {
|
||||
// If the animation is still running, fast-foward to 300ms from the end
|
||||
// If the animation is still running, fast-forward to 300ms from the end
|
||||
if (animation_is_scheduled(s_animation)) {
|
||||
uint32_t duration = animation_get_duration(s_animation, true, true);
|
||||
animation_set_elapsed(s_animation, duration - 300);
|
||||
@@ -142,7 +142,7 @@ static void click_handler(ClickRecognizerRef recognizer, Window *window) {
|
||||
}
|
||||
|
||||
/*
|
||||
// Exmple animation parameters:
|
||||
// Example animation parameters:
|
||||
|
||||
// Duration defaults to 250 ms
|
||||
animation_set_duration(&prop_animation->animation, 1000);
|
||||
|
||||
@@ -179,7 +179,7 @@ static void prv_window_load(Window *window) {
|
||||
// one image at the top left .topleft_layer,
|
||||
// and two menu layers .action_list1 and .action_list2 that overlay each other
|
||||
|
||||
// some hackery with the two menu layers goes on to keep their scroll offest in sync
|
||||
// some hackery with the two menu layers goes on to keep their scroll offset in sync
|
||||
// and to have the inverter layer rendered only once
|
||||
|
||||
const int16_t navbar_width = s_fps_topleft_bitmap.bounds.size.w;
|
||||
|
||||
@@ -1033,7 +1033,7 @@ static void prv_debug_cmd_heart_rate_api(int index, void *context) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// Test registring and cancelling a metric alert
|
||||
// Test registering and cancelling a metric alert
|
||||
HealthMetricAlert *alert = health_service_register_metric_alert(HealthMetricHeartRateBPM, 10);
|
||||
APP_LOG(APP_LOG_LEVEL_DEBUG, "Result from register_metric_alert: %p", alert);
|
||||
if (alert == NULL) {
|
||||
|
||||
1
src/bluetooth-fw/da1468x/.gitignore
vendored
Normal file
1
src/bluetooth-fw/da1468x/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!openocd.cfg
|
||||
52
src/bluetooth-fw/da1468x/common/dialog_utils.c
Normal file
52
src/bluetooth-fw/da1468x/common/dialog_utils.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dialog_utils.h"
|
||||
|
||||
// Dialog SDK:
|
||||
#include "ble_common.h"
|
||||
|
||||
#include <bluetooth/gap_le_connect.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
bool dialog_utils_dialog_is_addr_type_random(addr_type_t addr_type) {
|
||||
return (addr_type == PRIVATE_ADDRESS);
|
||||
}
|
||||
|
||||
addr_type_t dialog_utils_local_addr_type_to_dialog(const BTDeviceInternal *address) {
|
||||
return (address->is_random_address) ? PRIVATE_ADDRESS : PUBLIC_ADDRESS;
|
||||
}
|
||||
|
||||
void dialog_utils_bd_address_to_bt_device(const bd_address_t *addr, BTDeviceInternal *device_out) {
|
||||
*device_out = (BTDeviceInternal) {};
|
||||
device_out->is_random_address = dialog_utils_dialog_is_addr_type_random(addr->addr_type);
|
||||
memcpy(&device_out->address, &addr->addr, sizeof(device_out->address));
|
||||
}
|
||||
|
||||
void dialog_utils_bt_device_to_bd_address(const BTDeviceInternal *device, bd_address_t *addr_out) {
|
||||
addr_out->addr_type = dialog_utils_local_addr_type_to_dialog(device);
|
||||
memcpy(addr_out->addr, &device->address, sizeof(addr_out->addr));
|
||||
}
|
||||
|
||||
HciStatusCode ble_error_to_hci_status_error(ble_error_t e) {
|
||||
switch (e) {
|
||||
case BLE_STATUS_OK:
|
||||
return HciStatusCode_Success;
|
||||
default:
|
||||
return (e + HciStatusCode_VS_Base);
|
||||
}
|
||||
}
|
||||
54
src/bluetooth-fw/da1468x/common/hc_endpoint_bonding_sync.c
Normal file
54
src/bluetooth-fw/da1468x/common/hc_endpoint_bonding_sync.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bonding_sync_impl.h"
|
||||
#include "hc_protocol/hc_endpoint_bonding_sync.h"
|
||||
#include "hc_protocol/hc_protocol.h"
|
||||
|
||||
#include "kernel/pbl_malloc.h"
|
||||
#include "system/logging.h"
|
||||
|
||||
#include <bluetooth/bonding_sync.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void hc_endpoint_bonding_sync_handler(const HcProtocolMessage *msg) {
|
||||
switch (msg->command_id) {
|
||||
case HcMessageID_BondingSync_AddBonding:
|
||||
bonding_sync_handle_hc_add((const BleBonding *)msg->payload);
|
||||
break;
|
||||
case HcMessageID_BondingSync_RemoveBonding:
|
||||
bonding_sync_handle_hc_remove((const BleBonding *)msg->payload);
|
||||
break;
|
||||
|
||||
default:
|
||||
PBL_LOG(LOG_LEVEL_ERROR, "Unknown command ID: %"PRIu8, msg->command_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void prv_send_cmd(HcMessageID_BondingSync cmd_id, const BleBonding *bonding) {
|
||||
hc_protocol_enqueue_with_payload(HcEndpointID_BondingSync, cmd_id,
|
||||
(const uint8_t *)bonding, sizeof(*bonding));
|
||||
}
|
||||
|
||||
void hc_endpoint_bonding_sync_add(const BleBonding *bonding) {
|
||||
prv_send_cmd(HcMessageID_BondingSync_AddBonding, bonding);
|
||||
}
|
||||
|
||||
void hc_endpoint_bonding_sync_remove(const BleBonding *bonding) {
|
||||
prv_send_cmd(HcMessageID_BondingSync_RemoveBonding, bonding);
|
||||
}
|
||||
506
src/bluetooth-fw/da1468x/common/hc_protocol.c
Normal file
506
src/bluetooth-fw/da1468x/common/hc_protocol.c
Normal file
@@ -0,0 +1,506 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "core_dump.h"
|
||||
#include "hc_protocol/hc_protocol.h"
|
||||
#include "host_transport.h"
|
||||
|
||||
#include "kernel/pbl_malloc.h"
|
||||
#include "os/mutex.h"
|
||||
#include "os/tick.h"
|
||||
#include "system/logging.h"
|
||||
#include "system/passert.h"
|
||||
|
||||
#include "util/list.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
#include "task.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef enum HcProtocolState {
|
||||
HcProtoclStateNotInitialized = 0,
|
||||
HcProtoclStateIsInitialized,
|
||||
HcProtoclStateDeinitializing,
|
||||
} HcProtocolState;
|
||||
|
||||
#define TIMEOUT_TICKS (configTICK_RATE_HZ / 2)
|
||||
#define NUM_CONSEC_FAILURES 5
|
||||
|
||||
extern const HcProtocolMessageHandler g_hc_protocol_endpoints_table[HcEndpointIDCount];
|
||||
|
||||
typedef struct {
|
||||
ListNode node;
|
||||
SemaphoreHandle_t semaphore;
|
||||
const HcProtocolMessage *request;
|
||||
HcProtocolMessage *response;
|
||||
} HcExpectation;
|
||||
|
||||
static PebbleRecursiveMutex *s_hc_lock;
|
||||
static HcProtocolState s_hc_state;
|
||||
static HcExpectation *s_expectations_head;
|
||||
static uint8_t s_hc_next_transaction_id;
|
||||
static SemaphoreHandle_t s_retry_semph;
|
||||
|
||||
static volatile uint8_t s_outstanding_enqueues;
|
||||
|
||||
static uint8_t s_num_consec_enqueue_failures;
|
||||
#if !BT_CONTROLLER_BUILD
|
||||
static uint8_t s_num_consec_request_failures;
|
||||
#endif
|
||||
|
||||
static void prv_lock(void) {
|
||||
mutex_lock_recursive(s_hc_lock);
|
||||
}
|
||||
|
||||
static void prv_unlock(void) {
|
||||
mutex_unlock_recursive(s_hc_lock);
|
||||
}
|
||||
|
||||
static void prv_update_hc_state(HcProtocolState state) {
|
||||
prv_lock();
|
||||
s_hc_state = state;
|
||||
prv_unlock();
|
||||
}
|
||||
|
||||
//! WARNING: Will log if function is called and state is not initialized.
|
||||
static bool prv_check_initialized(void) {
|
||||
bool is_initialized;
|
||||
HcProtocolState state;
|
||||
prv_lock();
|
||||
{
|
||||
state = s_hc_state;
|
||||
is_initialized = (state == HcProtoclStateIsInitialized);
|
||||
}
|
||||
prv_unlock();
|
||||
if (!is_initialized) {
|
||||
PBL_LOG(LOG_LEVEL_WARNING, "prv_check_initialized called when hc_protocol is not initialized, "
|
||||
"state: %d", state);
|
||||
}
|
||||
return is_initialized;
|
||||
}
|
||||
|
||||
static TickType_t prv_remaining_ticks(TickType_t timeout_ticks, TickType_t start_ticks) {
|
||||
const TickType_t now = xTaskGetTickCount();
|
||||
const TickType_t elapsed = (now - start_ticks);
|
||||
if (timeout_ticks > elapsed) {
|
||||
return timeout_ticks - elapsed;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool prv_still_processing_enqueues(void) {
|
||||
bool done;
|
||||
prv_lock();
|
||||
{
|
||||
done = (s_outstanding_enqueues != 0);
|
||||
}
|
||||
prv_unlock();
|
||||
return done;
|
||||
}
|
||||
|
||||
// Only to be called by prv_enqueue(). This function keeps track of how many
|
||||
// enqueues are outstanding. If an enqueue is about to start but the stack is
|
||||
// no longer up, it does NOT bump the job count as we expect prv_enqueue() to
|
||||
// bail immediately
|
||||
static bool prv_update_enqueue_count(bool start) {
|
||||
bool initialized;
|
||||
prv_lock();
|
||||
{
|
||||
initialized = prv_check_initialized();
|
||||
if (initialized || !start) {
|
||||
s_outstanding_enqueues += (start) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
prv_unlock();
|
||||
return initialized;
|
||||
}
|
||||
|
||||
static bool prv_enqueue(HcProtocolMessage *message) {
|
||||
PBL_ASSERTN(message->message_length >= sizeof(HcProtocolMessage));
|
||||
|
||||
if (!prv_update_enqueue_count(true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = true;
|
||||
|
||||
// Retry for 500ms
|
||||
TickType_t start_ticks = xTaskGetTickCount();
|
||||
|
||||
while (1) {
|
||||
HostTransportEnqueueStatus status =
|
||||
host_transport_tx_enqueue((const uint8_t *)message, message->message_length);
|
||||
|
||||
if (status != HostTransportEnqueueStatus_RetryLater) {
|
||||
success = (status == HostTransportEnqueueStatus_Success);
|
||||
goto done;
|
||||
}
|
||||
|
||||
TickType_t remaining_ticks = prv_remaining_ticks(TIMEOUT_TICKS, start_ticks);
|
||||
|
||||
bool is_timeout;
|
||||
if (remaining_ticks == 0) {
|
||||
is_timeout = true;
|
||||
} else {
|
||||
is_timeout = (xSemaphoreTake(s_retry_semph, remaining_ticks) == pdFALSE);
|
||||
}
|
||||
|
||||
bool initialized = prv_check_initialized();
|
||||
if (is_timeout || !initialized) {
|
||||
PBL_LOG(LOG_LEVEL_ERROR, "Failed to enqueue HC request (endpoint:%d, command:%"PRIu8")",
|
||||
message->endpoint_id, message->command_id);
|
||||
s_num_consec_enqueue_failures++;
|
||||
if (initialized && (s_num_consec_enqueue_failures >= NUM_CONSEC_FAILURES)) {
|
||||
core_dump_and_reset_or_reboot();
|
||||
}
|
||||
success = false;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
s_num_consec_enqueue_failures = 0;
|
||||
|
||||
done:
|
||||
prv_update_enqueue_count(false /* stopping */);
|
||||
return success;
|
||||
}
|
||||
|
||||
static void prv_assign_next_transaction_id(HcProtocolMessage *message) {
|
||||
prv_lock();
|
||||
message->transaction_id.sn = s_hc_next_transaction_id;
|
||||
const uint8_t max_sn = ((1 << HC_PROTOCOL_SN_BIT_WIDTH) - 1);
|
||||
++s_hc_next_transaction_id;
|
||||
s_hc_next_transaction_id %= max_sn;
|
||||
prv_unlock();
|
||||
|
||||
message->transaction_id.is_response = false;
|
||||
}
|
||||
|
||||
bool hc_protocol_enqueue(HcProtocolMessage *message) {
|
||||
if (!prv_check_initialized()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
prv_assign_next_transaction_id(message);
|
||||
return prv_enqueue(message);
|
||||
}
|
||||
|
||||
static HcProtocolMessage *prv_create_message(HcEndpointID endpoint_id, HcCommandID command_id,
|
||||
const uint8_t *request_payload,
|
||||
size_t request_payload_length) {
|
||||
size_t message_length = sizeof(HcProtocolMessage) + request_payload_length;
|
||||
HcProtocolMessage *message = (HcProtocolMessage *)kernel_zalloc_check(message_length);
|
||||
message->message_length = message_length;
|
||||
message->endpoint_id = endpoint_id;
|
||||
message->command_id = command_id;
|
||||
if (request_payload_length) {
|
||||
memcpy(message->payload, request_payload, request_payload_length);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
bool hc_protocol_enqueue_with_payload(HcEndpointID endpoint_id, HcCommandID command_id,
|
||||
const uint8_t *request_payload,
|
||||
size_t request_payload_length) {
|
||||
if (!prv_check_initialized()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HcProtocolMessage *message = prv_create_message(endpoint_id, command_id, request_payload,
|
||||
request_payload_length);
|
||||
const bool rv = hc_protocol_enqueue(message);
|
||||
kernel_free(message);
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if !BT_CONTROLLER_BUILD
|
||||
static HcExpectation *prv_set_expectation_for_request(const HcProtocolMessage *request_message) {
|
||||
SemaphoreHandle_t semaphore = xSemaphoreCreateBinary();
|
||||
PBL_ASSERTN(semaphore);
|
||||
|
||||
HcExpectation *expectation = kernel_malloc_check(sizeof(HcExpectation));
|
||||
*expectation = (HcExpectation) {
|
||||
.semaphore = semaphore,
|
||||
.request = request_message,
|
||||
.response = NULL,
|
||||
};
|
||||
prv_lock();
|
||||
s_expectations_head = (HcExpectation *) list_prepend((ListNode *)s_expectations_head,
|
||||
&expectation->node);
|
||||
prv_unlock();
|
||||
return expectation;
|
||||
}
|
||||
|
||||
static void prv_cleanup_expectation(HcExpectation *expectation) {
|
||||
prv_lock();
|
||||
list_remove((ListNode *)expectation, (ListNode **)&s_expectations_head, NULL);
|
||||
prv_unlock();
|
||||
vSemaphoreDelete(expectation->semaphore);
|
||||
kernel_free(expectation);
|
||||
}
|
||||
|
||||
static HcProtocolMessage *prv_expect(HcExpectation *expectation) {
|
||||
HcProtocolMessage *response = NULL;
|
||||
// Save for debugging
|
||||
const HcCommandID cmd_id = expectation->request->command_id;
|
||||
const HcEndpointID end_id = expectation->request->endpoint_id;
|
||||
|
||||
TickType_t time_ticks = milliseconds_to_ticks(HC_PROTOCOL_DEFAULT_RESPONSE_TIMEOUT_MS);
|
||||
if (end_id == HcEndpointID_Ctl) {
|
||||
time_ticks = milliseconds_to_ticks(HC_PROTOCOL_DEFAULT_CTL_ENDPOINT_RESPONSE_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
xSemaphoreTake(expectation->semaphore, time_ticks);
|
||||
prv_lock();
|
||||
{
|
||||
// If we've timed out, expectation->response is NULL:
|
||||
response = expectation->response;
|
||||
// Set request to NULL, so it can't be matched any longer (important in timeout scenario)
|
||||
expectation->request = NULL;
|
||||
}
|
||||
prv_unlock();
|
||||
|
||||
if (response) {
|
||||
s_num_consec_request_failures = 0;
|
||||
} else {
|
||||
s_num_consec_request_failures++;
|
||||
PBL_LOG(LOG_LEVEL_ERROR, "HC request timed out (endpoint:%d, command:%"PRIu8")",
|
||||
end_id, cmd_id);
|
||||
if (prv_check_initialized() && (s_num_consec_request_failures >= NUM_CONSEC_FAILURES)) {
|
||||
core_dump_and_reset_or_reboot();
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
HcProtocolMessage *hc_protocol_enqueue_with_payload_and_expect(HcEndpointID endpoint_id,
|
||||
HcCommandID command_id,
|
||||
const uint8_t *request_payload,
|
||||
size_t request_payload_length) {
|
||||
if (!prv_check_initialized()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HcProtocolMessage *request = prv_create_message(endpoint_id, command_id, request_payload,
|
||||
request_payload_length);
|
||||
// `response` will be NULL if it failed.
|
||||
HcProtocolMessage *response = hc_protocol_enqueue_and_expect(request);
|
||||
kernel_free(request);
|
||||
return response;
|
||||
}
|
||||
|
||||
HcProtocolMessage *hc_protocol_enqueue_and_expect(HcProtocolMessage *request_message) {
|
||||
if (!prv_check_initialized()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't allow because we'd deadlock otherwise:
|
||||
PBL_ASSERTN(!host_transport_is_current_task_host_transport_task());
|
||||
|
||||
prv_assign_next_transaction_id(request_message);
|
||||
HcExpectation *expectation = prv_set_expectation_for_request(request_message);
|
||||
|
||||
if (!prv_enqueue(request_message)) {
|
||||
prv_cleanup_expectation(expectation);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HcProtocolMessage *response_message = prv_expect(expectation);
|
||||
prv_cleanup_expectation(expectation);
|
||||
|
||||
return response_message;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool hc_protocol_enqueue_response(const HcProtocolMessage *to_request,
|
||||
const uint8_t *response_payload, size_t response_payload_length) {
|
||||
if (!prv_check_initialized()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PBL_ASSERTN(!to_request->transaction_id.is_response);
|
||||
size_t message_length = sizeof(HcProtocolMessage) + response_payload_length;
|
||||
HcProtocolMessage *response = kernel_malloc_check(message_length);
|
||||
response->message_length = message_length;
|
||||
response->endpoint_id = to_request->endpoint_id;
|
||||
response->command_id = to_request->command_id;
|
||||
response->transaction_id.is_response = true;
|
||||
response->transaction_id.sn = to_request->transaction_id.sn;
|
||||
if (response_payload_length) {
|
||||
memcpy(response->payload, response_payload, response_payload_length);
|
||||
}
|
||||
bool rv = prv_enqueue(response);
|
||||
kernel_free(response);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static HcProtocolMessageHandler prv_get_handler_for_endpoint_id(HcEndpointID endpoint_id) {
|
||||
if (endpoint_id >= HcEndpointIDCount) {
|
||||
return NULL;
|
||||
}
|
||||
return g_hc_protocol_endpoints_table[endpoint_id];
|
||||
}
|
||||
|
||||
static void prv_dispatch_message_to_static_handler(HcProtocolMessage *message, bool *should_free) {
|
||||
const HcProtocolMessageHandler handler = prv_get_handler_for_endpoint_id(message->endpoint_id);
|
||||
if (!handler) {
|
||||
PBL_LOG(LOG_LEVEL_ERROR, "No handler for endpoint ID %u", message->endpoint_id);
|
||||
return;
|
||||
}
|
||||
|
||||
hc_protocol_cb_dispatch_handler(handler, message, should_free);
|
||||
}
|
||||
|
||||
static bool prv_expectation_for_message_list_filter_cb(ListNode *found_node, void *data) {
|
||||
HcExpectation *expectation = (HcExpectation *)found_node;
|
||||
const HcProtocolMessage *message = (const HcProtocolMessage *)data;
|
||||
if (!expectation->request) {
|
||||
// Already being handled or timed out.
|
||||
return false;
|
||||
}
|
||||
if (!message->transaction_id.is_response) {
|
||||
return false;
|
||||
}
|
||||
return (message->transaction_id.sn == expectation->request->transaction_id.sn);
|
||||
}
|
||||
|
||||
static HcExpectation *prv_expectation_for_message(HcProtocolMessage *message) {
|
||||
return (HcExpectation *)list_find((ListNode *)s_expectations_head,
|
||||
prv_expectation_for_message_list_filter_cb, message);
|
||||
}
|
||||
|
||||
static bool prv_try_handle_expectation(HcProtocolMessage *message, bool *should_free) {
|
||||
prv_lock();
|
||||
HcExpectation *expectation = prv_expectation_for_message(message);
|
||||
if (!expectation) {
|
||||
prv_unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make a heap copy if needed, or transfer ownership if the message is already heap-allocated:
|
||||
HcProtocolMessage *response_heap_copy;
|
||||
if (*should_free) {
|
||||
*should_free = false;
|
||||
response_heap_copy = message;
|
||||
} else {
|
||||
response_heap_copy = (HcProtocolMessage *) kernel_malloc_check(message->message_length);
|
||||
memcpy(response_heap_copy, message, message->message_length);
|
||||
}
|
||||
|
||||
expectation->response = response_heap_copy;
|
||||
xSemaphoreGive(expectation->semaphore);
|
||||
prv_unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
static HcProtocolMessage *prv_get_message(size_t length, bool *should_free) {
|
||||
uint8_t *rx_data = NULL;
|
||||
*should_free = host_transport_rx_read(&rx_data, length);
|
||||
return (HcProtocolMessage *) rx_data;
|
||||
}
|
||||
|
||||
void hc_protocol_process_receive_buffer(void) {
|
||||
if (!prv_check_initialized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t rx_length = host_transport_rx_get_length();
|
||||
while (rx_length) {
|
||||
if (rx_length < sizeof(HcProtocolMessage)) {
|
||||
// Header not received completely yet
|
||||
return;
|
||||
}
|
||||
|
||||
bool should_free = false;
|
||||
HcProtocolMessage *header = prv_get_message(sizeof(HcProtocolMessage), &should_free);
|
||||
const size_t message_length = header->message_length;
|
||||
if (should_free) {
|
||||
kernel_free(header);
|
||||
}
|
||||
|
||||
if (rx_length < message_length) {
|
||||
// Message not received completely yet
|
||||
return;
|
||||
}
|
||||
|
||||
HcProtocolMessage *message = prv_get_message(message_length, &should_free);
|
||||
if (!prv_try_handle_expectation(message, &should_free)) {
|
||||
prv_dispatch_message_to_static_handler(message, &should_free);
|
||||
}
|
||||
|
||||
host_transport_rx_consume(message_length);
|
||||
if (should_free) {
|
||||
kernel_free(message);
|
||||
}
|
||||
|
||||
rx_length -= message_length;
|
||||
}
|
||||
}
|
||||
|
||||
void hc_protocol_buffer_gained_space(void) {
|
||||
PBL_ASSERTN(s_retry_semph);
|
||||
xSemaphoreGive(s_retry_semph);
|
||||
}
|
||||
|
||||
//! Should be called only once at boot.
|
||||
void hc_protocol_boot(void) {
|
||||
if (s_hc_lock) {
|
||||
return;
|
||||
}
|
||||
s_hc_lock = mutex_create_recursive();
|
||||
}
|
||||
|
||||
//! Should be called when stack is brought up.
|
||||
void hc_protocol_init(void) {
|
||||
s_outstanding_enqueues = 0;
|
||||
s_hc_next_transaction_id = 0;
|
||||
s_retry_semph = xSemaphoreCreateBinary();
|
||||
prv_update_hc_state(HcProtoclStateIsInitialized);
|
||||
}
|
||||
|
||||
//! Should be called when stack is torn down.
|
||||
void hc_protocol_deinit(void) {
|
||||
prv_update_hc_state(HcProtoclStateDeinitializing);
|
||||
|
||||
while (prv_still_processing_enqueues()) {
|
||||
// Give the semaphore in case a task is waiting on it
|
||||
xSemaphoreGive(s_retry_semph);
|
||||
// Give the task some time to process it
|
||||
vTaskDelay(2);
|
||||
}
|
||||
|
||||
// At this point it should no longer be possible for someone to use the retry
|
||||
// semaphore so delete it
|
||||
SemaphoreHandle_t s_retry_semph_tmp = s_retry_semph;
|
||||
s_retry_semph = NULL;
|
||||
vSemaphoreDelete(s_retry_semph_tmp);
|
||||
|
||||
prv_lock();
|
||||
HcExpectation *expectation = s_expectations_head;
|
||||
while (expectation) {
|
||||
if (!expectation->request) {
|
||||
// Semaphore already given or timed out, so skip it.
|
||||
continue;
|
||||
}
|
||||
// Just give, the expectation + semaphore should get cleaned up automatically now.
|
||||
xSemaphoreGive(expectation->semaphore);
|
||||
expectation = (HcExpectation *) list_get_next(&expectation->node);
|
||||
}
|
||||
prv_unlock();
|
||||
}
|
||||
94
src/bluetooth-fw/da1468x/controller/board/board_robert.c
Normal file
94
src/bluetooth-fw/da1468x/controller/board/board_robert.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
|
||||
static const BoardConfigHostSPI s_host_spi = {
|
||||
.mcu_int = {
|
||||
.port = HW_GPIO_PORT_2,
|
||||
.pin = HW_GPIO_PIN_3,
|
||||
.function = HW_GPIO_FUNC_GPIO,
|
||||
},
|
||||
|
||||
.spi = {
|
||||
.peripheral = HW_SPI1,
|
||||
.cs = {
|
||||
.port = HW_GPIO_PORT_0,
|
||||
.pin = HW_GPIO_PIN_1,
|
||||
.function = HW_GPIO_FUNC_SPI_EN,
|
||||
},
|
||||
.cs_2 = {
|
||||
.port = HW_GPIO_PORT_0,
|
||||
.pin = HW_GPIO_PIN_7,
|
||||
.function = HW_GPIO_FUNC_GPIO,
|
||||
},
|
||||
.clk = {
|
||||
.port = HW_GPIO_PORT_0,
|
||||
.pin = HW_GPIO_PIN_0,
|
||||
.function = HW_GPIO_FUNC_SPI_CLK,
|
||||
},
|
||||
.miso_do = {
|
||||
.port = HW_GPIO_PORT_1,
|
||||
.pin = HW_GPIO_PIN_3,
|
||||
.function = HW_GPIO_FUNC_SPI_DO,
|
||||
},
|
||||
.mosi_di = {
|
||||
.port = HW_GPIO_PORT_0,
|
||||
.pin = HW_GPIO_PIN_4,
|
||||
.function = HW_GPIO_FUNC_SPI_DI,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
// These are spare GPIOs on both the SILK and ROBERT bigboards which are broken out to a header
|
||||
// Check out debug_gpio.h for more info on how to leverage them for debug
|
||||
static BoardConfigGpioDebug s_debug_gpios = {
|
||||
.num_debug_gpios = 4,
|
||||
.debug_gpio = {
|
||||
[0] = {
|
||||
.port = HW_GPIO_PORT_3,
|
||||
.pin = HW_GPIO_PIN_0,
|
||||
},
|
||||
[1] = {
|
||||
.port = HW_GPIO_PORT_3,
|
||||
.pin = HW_GPIO_PIN_1,
|
||||
},
|
||||
[2] = {
|
||||
.port = HW_GPIO_PORT_3,
|
||||
.pin = HW_GPIO_PIN_2,
|
||||
},
|
||||
[3] = {
|
||||
.port = HW_GPIO_PORT_3,
|
||||
.pin = HW_GPIO_PIN_3,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static const BoardConfigBTFEM s_bt_fem = {
|
||||
.rx = {
|
||||
.port = HW_GPIO_PORT_1,
|
||||
.pin = HW_GPIO_PIN_6,
|
||||
},
|
||||
.tx = {
|
||||
.port = HW_GPIO_PORT_1,
|
||||
.pin = HW_GPIO_PIN_7,
|
||||
},
|
||||
};
|
||||
|
||||
const BoardConfigHostSPI * const HOST_SPI = &s_host_spi;
|
||||
BoardConfigGpioDebug * const DEBUG_GPIOS = &s_debug_gpios;
|
||||
const BoardConfigBTFEM * const BT_FEM = &s_bt_fem;
|
||||
81
src/bluetooth-fw/da1468x/controller/board/board_silk.c
Normal file
81
src/bluetooth-fw/da1468x/controller/board/board_silk.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
|
||||
static const BoardConfigHostSPI s_host_spi = {
|
||||
.mcu_int = {
|
||||
.port = HW_GPIO_PORT_2,
|
||||
.pin = HW_GPIO_PIN_3,
|
||||
.function = HW_GPIO_FUNC_GPIO,
|
||||
},
|
||||
|
||||
.spi = {
|
||||
.peripheral = HW_SPI1,
|
||||
.cs = {
|
||||
.port = HW_GPIO_PORT_0,
|
||||
.pin = HW_GPIO_PIN_1,
|
||||
.function = HW_GPIO_FUNC_SPI_EN,
|
||||
},
|
||||
.cs_2 = {
|
||||
.port = HW_GPIO_PORT_0,
|
||||
.pin = HW_GPIO_PIN_7,
|
||||
.function = HW_GPIO_FUNC_GPIO,
|
||||
},
|
||||
.clk = {
|
||||
.port = HW_GPIO_PORT_0,
|
||||
.pin = HW_GPIO_PIN_0,
|
||||
.function = HW_GPIO_FUNC_SPI_CLK,
|
||||
},
|
||||
.miso_do = {
|
||||
.port = HW_GPIO_PORT_1,
|
||||
.pin = HW_GPIO_PIN_3,
|
||||
.function = HW_GPIO_FUNC_SPI_DO,
|
||||
},
|
||||
.mosi_di = {
|
||||
.port = HW_GPIO_PORT_0,
|
||||
.pin = HW_GPIO_PIN_4,
|
||||
.function = HW_GPIO_FUNC_SPI_DI,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
// These are spare GPIOs on both the SILK and ROBERT bigboards which are broken out to a header
|
||||
// Check out debug_gpio.h for more info on how to leverage them for debug
|
||||
static BoardConfigGpioDebug s_debug_gpios = {
|
||||
.num_debug_gpios = 4,
|
||||
.debug_gpio = {
|
||||
[0] = {
|
||||
.port = HW_GPIO_PORT_3,
|
||||
.pin = HW_GPIO_PIN_0,
|
||||
},
|
||||
[1] = {
|
||||
.port = HW_GPIO_PORT_3,
|
||||
.pin = HW_GPIO_PIN_1,
|
||||
},
|
||||
[2] = {
|
||||
.port = HW_GPIO_PORT_3,
|
||||
.pin = HW_GPIO_PIN_2,
|
||||
},
|
||||
[3] = {
|
||||
.port = HW_GPIO_PORT_3,
|
||||
.pin = HW_GPIO_PIN_3,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const BoardConfigHostSPI * const HOST_SPI = &s_host_spi;
|
||||
BoardConfigGpioDebug * const DEBUG_GPIOS = &s_debug_gpios;
|
||||
66
src/bluetooth-fw/da1468x/controller/board/include/board.h
Normal file
66
src/bluetooth-fw/da1468x/controller/board/include/board.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hw_gpio.h"
|
||||
#include "hw_spi.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct GPIOPortPin {
|
||||
HW_GPIO_PORT port;
|
||||
HW_GPIO_PIN pin;
|
||||
HW_GPIO_FUNC function;
|
||||
} GPIOPortPin;
|
||||
|
||||
typedef struct {
|
||||
// BT Controller to MCU INT line:
|
||||
GPIOPortPin mcu_int;
|
||||
|
||||
// BT Controller SPI slave:
|
||||
struct {
|
||||
HW_SPI_ID *peripheral;
|
||||
GPIOPortPin cs;
|
||||
GPIOPortPin cs_2;
|
||||
GPIOPortPin clk;
|
||||
GPIOPortPin miso_do;
|
||||
GPIOPortPin mosi_di;
|
||||
} spi;
|
||||
} BoardConfigHostSPI;
|
||||
|
||||
typedef struct DebugGPIOInfo {
|
||||
HW_GPIO_PORT port;
|
||||
HW_GPIO_PIN pin;
|
||||
bool is_active;
|
||||
} DebugGPIOInfo;
|
||||
|
||||
typedef struct BoardConfigGpioDebug {
|
||||
int num_debug_gpios;
|
||||
DebugGPIOInfo debug_gpio[];
|
||||
} BoardConfigGpioDebug;
|
||||
|
||||
typedef struct {
|
||||
// BT FEM
|
||||
GPIOPortPin rx;
|
||||
GPIOPortPin tx;
|
||||
} BoardConfigBTFEM;
|
||||
|
||||
extern const BoardConfigHostSPI * const HOST_SPI;
|
||||
extern BoardConfigGpioDebug * const DEBUG_GPIOS;
|
||||
extern const BoardConfigBTFEM * const BT_FEM;
|
||||
|
||||
#include "board_definitions.h"
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#if PLATFORM_SILK
|
||||
#include "board_silk.h"
|
||||
#elif PLATFORM_CALCULUS || PLATFORM_ROBERT
|
||||
#include "board_robert.h"
|
||||
#else
|
||||
#error "Unknown board definition"
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Note TX DMA channel is assumed to be RX DMA channel + 1, see SPI_SLAVE_TO_EXT_MASTER
|
||||
#define HOST_SPI_RX_DMA_CHANNEL (HW_DMA_CHANNEL_0)
|
||||
#define HOST_SPI_TX_DMA_CHANNEL (HW_DMA_CHANNEL_1)
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Note TX DMA channel is assumed to be RX DMA channel + 1, see SPI_SLAVE_TO_EXT_MASTER
|
||||
#define HOST_SPI_RX_DMA_CHANNEL (HW_DMA_CHANNEL_0)
|
||||
#define HOST_SPI_TX_DMA_CHANNEL (HW_DMA_CHANNEL_1)
|
||||
27
src/bluetooth-fw/da1468x/controller/board/wscript_build
Normal file
27
src/bluetooth-fw/da1468x/controller/board/wscript_build
Normal file
@@ -0,0 +1,27 @@
|
||||
def _build_board(source_file, name, config_h, idx):
|
||||
bld.objects(
|
||||
name=name,
|
||||
source=[source_file],
|
||||
use=['dialog_sdk_includes'],
|
||||
export_includes=['include'],
|
||||
includes=['include'],
|
||||
inject_include_files=[config_h],
|
||||
idx=idx,
|
||||
)
|
||||
|
||||
board = bld.env.BOARD
|
||||
if board in ('silk_evt', 'silk_bb', 'silk_bb2', 'silk'):
|
||||
_build_board('board_silk.c', 'dialog_board_main',
|
||||
'../main/config/custom_config_main.h', 3000)
|
||||
_build_board('board_silk.c', 'dialog_board_boot',
|
||||
'../boot/config/custom_config_boot.h', 4000)
|
||||
elif board in ('robert_bb', 'robert_bb2', 'robert_evt', 'cutts_bb'):
|
||||
_build_board('board_robert.c', 'dialog_board_main',
|
||||
'../main/config/custom_config_main.h', 3000)
|
||||
_build_board('board_robert.c', 'dialog_board_boot',
|
||||
'../boot/config/custom_config_boot.h', 4000)
|
||||
else:
|
||||
print bld.env
|
||||
bld.fatal('Unknown board {}'.format(board))
|
||||
|
||||
# vim:filetype=python
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
void debug_print_str(const char *str);
|
||||
void debug_print_hex(int val);
|
||||
void debug_print_str_and_int(const char *str, int value);
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Initializes Dialog part as a SPI Slave and puts a firmware load in motion.
|
||||
// See host_transport.c for implementation details
|
||||
void host_transport_begin(void);
|
||||
127
src/bluetooth-fw/da1468x/controller/boot/ldscripts/mem.ld.h
Normal file
127
src/bluetooth-fw/da1468x/controller/boot/ldscripts/mem.ld.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "da1468x_mem_map.h"
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with other linker script that defines memory regions CODE_AND_RAM
|
||||
* It references following symbols, which must be defined in code:
|
||||
* Reset_Handler : Entry of reset handler
|
||||
*
|
||||
* It defines following symbols, which code can use without definition:
|
||||
* __zero_table_start__
|
||||
* __zero_table_end__
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
CODE_AND_RAM (rwx): ORIGIN = DATA_RAM_BASE_ADDRESS, LENGTH = 10 * 1024
|
||||
}
|
||||
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.isr_vector))
|
||||
/* make sure that IVT doesn't cross 0xC0 */
|
||||
. = 0xC0;
|
||||
|
||||
KEEP(*(.patch_table))
|
||||
KEEP(*(.default_patch_code_handler_section))
|
||||
|
||||
*(.text*)
|
||||
|
||||
*(.rodata*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > CODE_AND_RAM
|
||||
|
||||
/* To clear multiple BSS sections,
|
||||
* uncomment .zero.table section and,
|
||||
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
|
||||
.zero.table :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__zero_table_start__ = .;
|
||||
LONG (__bss_start__)
|
||||
LONG (__bss_end__ - __bss_start__)
|
||||
__zero_table_end__ = .;
|
||||
} > CODE_AND_RAM
|
||||
|
||||
__etext = .;
|
||||
|
||||
/* The initialised data section is stored immediately
|
||||
at the end of the text section */
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init_array/fini_array moved to flash, align preserved */
|
||||
|
||||
KEEP(*(.jcr*))
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
} > CODE_AND_RAM
|
||||
|
||||
/* GNU build id: This is a hash of parts of the binary that uniquely
|
||||
* identifies the binary. This hash gets inserted by the linker;
|
||||
* we're passing the flag --build-id=sha1 to do this.
|
||||
* The variable DIALOG_BUILD_ID is provided, so that the values can be used
|
||||
* in the firmware code. */
|
||||
.note.gnu.build-id : {
|
||||
PROVIDE(DIALOG_BUILD_ID = .);
|
||||
KEEP(*(.note.gnu.build-id))
|
||||
} > CODE_AND_RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
*(retention_mem_zi)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > CODE_AND_RAM
|
||||
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only a
|
||||
* a placeholder for where the ISR stack lives. */
|
||||
.stack_dummy (COPY):
|
||||
{
|
||||
__StackBottom = .;
|
||||
*(.stack*)
|
||||
} > CODE_AND_RAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(CODE_AND_RAM) + LENGTH(CODE_AND_RAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
}
|
||||
35
src/bluetooth-fw/da1468x/controller/boot/src/debug_print.c
Normal file
35
src/bluetooth-fw/da1468x/controller/boot/src/debug_print.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "util/string.h"
|
||||
|
||||
extern int _write(int file, char *ptr, int len);
|
||||
|
||||
void debug_print_str(char *str) {
|
||||
_write(0, str, strlen(str));
|
||||
}
|
||||
|
||||
void debug_print_hex(int val) {
|
||||
char buffer[12] = { };
|
||||
itoa(val, buffer, sizeof(buffer));
|
||||
debug_print_str(buffer);
|
||||
}
|
||||
|
||||
void debug_print_str_and_int(char *str, int value) {
|
||||
debug_print_str(str);
|
||||
debug_print_hex(value);
|
||||
debug_print_str("\n");
|
||||
}
|
||||
486
src/bluetooth-fw/da1468x/controller/boot/src/default_registers.c
Normal file
486
src/bluetooth-fw/da1468x/controller/boot/src/default_registers.c
Normal file
@@ -0,0 +1,486 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "sdk_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// If Dialog ever updates the number of registers or the default values of the registers, one can:
|
||||
// 1. Set `DEFAULT_REGISTER_DEBUG` to 1
|
||||
// 2. Update/Add/Remove the register values using `REG_SETF`
|
||||
// 3. Flash and boot the dialog chip.
|
||||
// 4. Attach GDB to ble chip and type `p/x ALL_REGISTERS`
|
||||
// 5. Copy, reformat, and paste output to the squashed register values.
|
||||
|
||||
#define DEFAULT_REGISTER_DEBUG 0
|
||||
|
||||
#if DEFAULT_REGISTER_DEBUG
|
||||
typedef struct AllRegisters {
|
||||
// DCDC
|
||||
uint16_t DCDC_CTRL_0_REG;
|
||||
uint16_t DCDC_CTRL_1_REG;
|
||||
uint16_t DCDC_CTRL_2_REG;
|
||||
uint16_t DCDC_V14_0_REG;
|
||||
uint16_t DCDC_V14_1_REG;
|
||||
uint16_t DCDC_V18_0_REG;
|
||||
uint16_t DCDC_V18_1_REG;
|
||||
uint16_t DCDC_VDD_0_REG;
|
||||
uint16_t DCDC_VDD_1_REG;
|
||||
uint16_t DCDC_V18P_0_REG;
|
||||
uint16_t DCDC_V18P_1_REG;
|
||||
uint16_t DCDC_RET_0_REG;
|
||||
uint16_t DCDC_RET_1_REG;
|
||||
uint16_t DCDC_TRIM_REG;
|
||||
uint16_t DCDC_TEST_0_REG;
|
||||
uint16_t DCDC_TEST_1_REG;
|
||||
uint16_t DCDC_IRQ_CLEAR_REG;
|
||||
uint16_t DCDC_IRQ_MASK_REG;
|
||||
|
||||
// CRG_TOP
|
||||
uint16_t BANDGAP_REG;
|
||||
uint16_t BOD_STATUS_REG;
|
||||
uint16_t FORCE_SLEEP_REG;
|
||||
uint16_t LDOS_DISABLE_REG;
|
||||
uint16_t AON_SPARE_REG;
|
||||
|
||||
// QSPIC
|
||||
uint32_t QSPIC_CTRLMODE_REG;
|
||||
uint32_t QSPIC_BURSTCMDA_REG;
|
||||
uint32_t QSPIC_BURSTCMDB_REG;
|
||||
uint32_t QSPIC_WRITEDATA_REG;
|
||||
uint32_t QSPIC_DUMMYDATA_REG;
|
||||
uint32_t QSPIC_ERASECTRL_REG;
|
||||
uint32_t QSPIC_ERASECMDA_REG;
|
||||
uint32_t QSPIC_ERASECMDB_REG;
|
||||
uint32_t QSPIC_BURSTBRK_REG;
|
||||
uint32_t QSPIC_STATUSCMD_REG;
|
||||
uint32_t QSPIC_CHCKERASE_REG;
|
||||
uint32_t QSPIC_GP_REG;
|
||||
uint32_t QSPIC_UCODE_START;
|
||||
|
||||
// GPREG
|
||||
uint16_t PLL_SYS_CTRL1_REG;
|
||||
uint16_t PLL_SYS_CTRL2_REG;
|
||||
uint16_t PLL_SYS_CTRL3_REG;
|
||||
uint16_t PLL_SYS_TEST_REG;
|
||||
|
||||
// CACHE
|
||||
uint32_t CACHE_CTRL1_REG;
|
||||
uint32_t CACHE_LNSIZECFG_REG;
|
||||
uint32_t CACHE_ASSOCCFG_REG;
|
||||
uint32_t CACHE_CTRL2_REG;
|
||||
uint32_t CACHE_CTRL3_REG;
|
||||
uint32_t CACHE_MRM_HITS_REG;
|
||||
uint32_t CACHE_MRM_MISSES_REG;
|
||||
uint32_t CACHE_MRM_CTRL_REG;
|
||||
uint32_t CACHE_MRM_TINT_REG;
|
||||
uint32_t CACHE_MRM_THRES_REG;
|
||||
uint32_t SWD_RESET_REG;
|
||||
} AllRegisters;
|
||||
|
||||
static AllRegisters ALL_REGISTERS;
|
||||
|
||||
#endif // DEFAULT_REGISTER_DEBUG
|
||||
|
||||
|
||||
void default_registers_restore(void) {
|
||||
DCDC->DCDC_CTRL_0_REG = 0x2f24;
|
||||
DCDC->DCDC_CTRL_1_REG = 0x5410;
|
||||
DCDC->DCDC_CTRL_2_REG = 0x882d;
|
||||
DCDC->DCDC_V14_0_REG = 0xa1a4;
|
||||
DCDC->DCDC_V14_1_REG = 0xd890;
|
||||
DCDC->DCDC_V18_0_REG = 0xe3e4;
|
||||
DCDC->DCDC_V18_1_REG = 0xbc90;
|
||||
DCDC->DCDC_VDD_0_REG = 0xc304;
|
||||
DCDC->DCDC_VDD_1_REG = 0xec90;
|
||||
DCDC->DCDC_V18P_0_REG = 0xe3e4;
|
||||
DCDC->DCDC_V18P_1_REG = 0xbc90;
|
||||
DCDC->DCDC_RET_0_REG = 0xaaa6;
|
||||
DCDC->DCDC_RET_1_REG = 0xaa46;
|
||||
DCDC->DCDC_TRIM_REG = 0x0;
|
||||
DCDC->DCDC_TEST_0_REG = 0x0;
|
||||
DCDC->DCDC_TEST_1_REG = 0x0;
|
||||
DCDC->DCDC_IRQ_CLEAR_REG = 0x0;
|
||||
DCDC->DCDC_IRQ_MASK_REG = 0x0;
|
||||
CRG_TOP->BANDGAP_REG = 0x0;
|
||||
CRG_TOP->BOD_STATUS_REG = 0x7;
|
||||
CRG_TOP->FORCE_SLEEP_REG = 0x1;
|
||||
CRG_TOP->LDOS_DISABLE_REG = 0x0;
|
||||
CRG_TOP->AON_SPARE_REG = 0x0;
|
||||
QSPIC->QSPIC_CTRLBUS_REG = 0x0;
|
||||
QSPIC->QSPIC_CTRLMODE_REG = 0x0;
|
||||
QSPIC->QSPIC_BURSTCMDA_REG = 0x0;
|
||||
QSPIC->QSPIC_BURSTCMDB_REG = 0x0;
|
||||
QSPIC->QSPIC_WRITEDATA_REG = 0x0;
|
||||
QSPIC->QSPIC_DUMMYDATA_REG = 0x0;
|
||||
QSPIC->QSPIC_ERASECTRL_REG = 0x0;
|
||||
QSPIC->QSPIC_ERASECMDA_REG = 0x0;
|
||||
QSPIC->QSPIC_ERASECMDB_REG = 0x0;
|
||||
QSPIC->QSPIC_BURSTBRK_REG = 0x0;
|
||||
QSPIC->QSPIC_STATUSCMD_REG = 0x0;
|
||||
QSPIC->QSPIC_CHCKERASE_REG = 0x0;
|
||||
QSPIC->QSPIC_GP_REG = 0x0;
|
||||
QSPIC->QSPIC_UCODE_START = 0x0;
|
||||
GPREG->PLL_SYS_CTRL1_REG = 0x100;
|
||||
GPREG->PLL_SYS_CTRL2_REG = 0x2006;
|
||||
GPREG->PLL_SYS_CTRL3_REG = 0x3c09;
|
||||
GPREG->PLL_SYS_TEST_REG = 0x70;
|
||||
CACHE->CACHE_CTRL1_REG = 0x0;
|
||||
CACHE->CACHE_LNSIZECFG_REG = 0x0;
|
||||
CACHE->CACHE_ASSOCCFG_REG = 0x2;
|
||||
CACHE->CACHE_CTRL2_REG = 0x0;
|
||||
CACHE->CACHE_CTRL3_REG = 0x22;
|
||||
CACHE->CACHE_MRM_HITS_REG = 0x0;
|
||||
CACHE->CACHE_MRM_MISSES_REG = 0x0;
|
||||
CACHE->CACHE_MRM_CTRL_REG = 0x0;
|
||||
CACHE->CACHE_MRM_TINT_REG = 0x0;
|
||||
CACHE->CACHE_MRM_THRES_REG = 0x0;
|
||||
CACHE->SWD_RESET_REG = 0x0;
|
||||
|
||||
#if DEFAULT_REGISTER_DEBUG
|
||||
// DCDC
|
||||
REG_SETF(DCDC, DCDC_CTRL_0_REG, DCDC_FAST_STARTUP, 0x0);
|
||||
REG_SETF(DCDC, DCDC_CTRL_0_REG, DCDC_BROWNOUT_LV_MODE, 0x1);
|
||||
REG_SETF(DCDC, DCDC_CTRL_0_REG, DCDC_IDLE_CLK_DIV, 0x1);
|
||||
REG_SETF(DCDC, DCDC_CTRL_0_REG, DCDC_PRIORITY, 0xE4);
|
||||
REG_SETF(DCDC, DCDC_CTRL_0_REG, DCDC_FW_ENABLE, 0x1);
|
||||
REG_SETF(DCDC, DCDC_CTRL_0_REG, DCDC_MODE, 0);
|
||||
|
||||
REG_SETF(DCDC, DCDC_CTRL_1_REG, DCDC_STARTUP_DELAY, 0xA);
|
||||
REG_SETF(DCDC, DCDC_CTRL_1_REG, DCDC_GLOBAL_MAX_IDLE_TIME, 0x20);
|
||||
REG_SETF(DCDC, DCDC_CTRL_1_REG, DCDC_TIMEOUT, 0x10);
|
||||
|
||||
REG_SETF(DCDC, DCDC_CTRL_2_REG, DCDC_TIMEOUT_IRQ_TRIG, 0x8);
|
||||
REG_SETF(DCDC, DCDC_CTRL_2_REG, DCDC_TIMEOUT_IRQ_RES, 0x8);
|
||||
REG_SETF(DCDC, DCDC_CTRL_2_REG, DCDC_TUNE, 0x0);
|
||||
REG_SETF(DCDC, DCDC_CTRL_2_REG, DCDC_LSSUP_TRIM, 0x5);
|
||||
REG_SETF(DCDC, DCDC_CTRL_2_REG, DCDC_HSGND_TRIM, 0x5);
|
||||
|
||||
REG_SETF(DCDC, DCDC_V14_0_REG, DCDC_V14_FAST_RAMPING, 0x1);
|
||||
REG_SETF(DCDC, DCDC_V14_0_REG, DCDC_V14_VOLTAGE, 0x8);
|
||||
REG_SETF(DCDC, DCDC_V14_0_REG, DCDC_V14_CUR_LIM_MAX_HV, 0xD);
|
||||
REG_SETF(DCDC, DCDC_V14_0_REG, DCDC_V14_CUR_LIM_MIN, 0x4);
|
||||
|
||||
REG_SETF(DCDC, DCDC_V14_1_REG, DCDC_V14_ENABLE_HV, 0x1);
|
||||
REG_SETF(DCDC, DCDC_V14_1_REG, DCDC_V14_ENABLE_LV, 0x1);
|
||||
REG_SETF(DCDC, DCDC_V14_1_REG, DCDC_V14_CUR_LIM_MAX_LV, 0x6);
|
||||
REG_SETF(DCDC, DCDC_V14_1_REG, DCDC_V14_IDLE_HYST, 0x4);
|
||||
REG_SETF(DCDC, DCDC_V14_1_REG, DCDC_V14_IDLE_MIN, 0x10);
|
||||
|
||||
REG_SETF(DCDC, DCDC_V18_0_REG, DCDC_V18_FAST_RAMPING, 0x1);
|
||||
REG_SETF(DCDC, DCDC_V18_0_REG, DCDC_V18_VOLTAGE, 0x18);
|
||||
REG_SETF(DCDC, DCDC_V18_0_REG, DCDC_V18_CUR_LIM_MAX_HV, 0x1F);
|
||||
REG_SETF(DCDC, DCDC_V18_0_REG, DCDC_V18_CUR_LIM_MIN, 0x4);
|
||||
|
||||
REG_SETF(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_HV, 0x1);
|
||||
REG_SETF(DCDC, DCDC_V18_1_REG, DCDC_V18_ENABLE_LV, 0x0);
|
||||
REG_SETF(DCDC, DCDC_V18_1_REG, DCDC_V18_CUR_LIM_MAX_LV, 0xF);
|
||||
REG_SETF(DCDC, DCDC_V18_1_REG, DCDC_V18_IDLE_HYST, 0x4);
|
||||
REG_SETF(DCDC, DCDC_V18_1_REG, DCDC_V18_IDLE_MIN, 0x10);
|
||||
|
||||
REG_SETF(DCDC, DCDC_VDD_0_REG, DCDC_VDD_FAST_RAMPING, 0x1);
|
||||
REG_SETF(DCDC, DCDC_VDD_0_REG, DCDC_VDD_VOLTAGE, 0x10);
|
||||
REG_SETF(DCDC, DCDC_VDD_0_REG, DCDC_VDD_CUR_LIM_MAX_HV, 0x18);
|
||||
REG_SETF(DCDC, DCDC_VDD_0_REG, DCDC_VDD_CUR_LIM_MIN, 0x4);
|
||||
|
||||
REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_ENABLE_HV, 0x1);
|
||||
REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_ENABLE_LV, 0x1);
|
||||
REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_CUR_LIM_MAX_LV, 0xB);
|
||||
REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_IDLE_HYST, 0x4);
|
||||
REG_SETF(DCDC, DCDC_VDD_1_REG, DCDC_VDD_IDLE_MIN, 0x10);
|
||||
|
||||
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_FAST_RAMPING, 0x1);
|
||||
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_VOLTAGE, 0x18);
|
||||
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_CUR_LIM_MAX_HV, 0x1F);
|
||||
REG_SETF(DCDC, DCDC_V18P_0_REG, DCDC_V18P_CUR_LIM_MIN, 0x4);
|
||||
|
||||
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_ENABLE_HV, 0x1);
|
||||
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_ENABLE_LV, 0x0);
|
||||
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_CUR_LIM_MAX_LV, 0xF);
|
||||
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_IDLE_HYST, 0x4);
|
||||
REG_SETF(DCDC, DCDC_V18P_1_REG, DCDC_V18P_IDLE_MIN, 0x10);
|
||||
|
||||
REG_SETF(DCDC, DCDC_RET_0_REG, DCDC_V18P_RET_CYCLES, 0x5);
|
||||
REG_SETF(DCDC, DCDC_RET_0_REG, DCDC_V18P_CUR_LIM_RET, 0xA);
|
||||
REG_SETF(DCDC, DCDC_RET_0_REG, DCDC_VDD_RET_CYCLES, 0x5);
|
||||
REG_SETF(DCDC, DCDC_RET_0_REG, DCDC_VDD_CUR_LIM_RET, 0x6);
|
||||
|
||||
REG_SETF(DCDC, DCDC_RET_1_REG, DCDC_V18_RET_CYCLES, 0x5);
|
||||
REG_SETF(DCDC, DCDC_RET_1_REG, DCDC_V18_CUR_LIM_RET, 0xA);
|
||||
REG_SETF(DCDC, DCDC_RET_1_REG, DCDC_V14_RET_CYCLES, 0x2);
|
||||
REG_SETF(DCDC, DCDC_RET_1_REG, DCDC_V14_CUR_LIM_RET, 0x6);
|
||||
|
||||
REG_SETF(DCDC, DCDC_TRIM_REG, DCDC_P_COMP_MAN_TRIM, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TRIM_REG, DCDC_P_COMP_TRIM, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TRIM_REG, DCDC_N_COMP_MAN_TRIM, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TRIM_REG, DCDC_N_COMP_TRIM, 0x0);
|
||||
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_COMP_CLK, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_CURRENT, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_OUTPUT_MONITOR, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_ANA_TEST, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_IDLE, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_V18P, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_VDD, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_V18, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_V14, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_FW, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_NSW, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_0_REG, DCDC_FORCE_PSW, 0x0);
|
||||
|
||||
REG_SETF(DCDC, DCDC_TEST_1_REG, DCDC_COMP_CLK, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_1_REG, DCDC_TEST_CURRENT, 0x0);
|
||||
REG_SETF(DCDC, DCDC_TEST_1_REG, DCDC_TEST_REG, 0x0);
|
||||
|
||||
REG_SETF(DCDC, DCDC_IRQ_CLEAR_REG, DCDC_BROWN_OUT_IRQ_CLEAR, 0x0);
|
||||
REG_SETF(DCDC, DCDC_IRQ_CLEAR_REG, DCDC_V18P_TIMEOUT_IRQ_CLEAR, 0x0);
|
||||
REG_SETF(DCDC, DCDC_IRQ_CLEAR_REG, DCDC_VDD_TIMEOUT_IRQ_CLEAR, 0x0);
|
||||
REG_SETF(DCDC, DCDC_IRQ_CLEAR_REG, DCDC_V18_TIMEOUT_IRQ_CLEAR, 0x0);
|
||||
REG_SETF(DCDC, DCDC_IRQ_CLEAR_REG, DCDC_V14_TIMEOUT_IRQ_CLEAR, 0x0);
|
||||
|
||||
REG_SETF(DCDC, DCDC_IRQ_MASK_REG, DCDC_BROWN_OUT_IRQ_MASK, 0x0);
|
||||
REG_SETF(DCDC, DCDC_IRQ_MASK_REG, DCDC_V18P_TIMEOUT_IRQ_MASK, 0x0);
|
||||
REG_SETF(DCDC, DCDC_IRQ_MASK_REG, DCDC_VDD_TIMEOUT_IRQ_MASK, 0x0);
|
||||
REG_SETF(DCDC, DCDC_IRQ_MASK_REG, DCDC_V18_TIMEOUT_IRQ_MASK, 0x0);
|
||||
REG_SETF(DCDC, DCDC_IRQ_MASK_REG, DCDC_V14_TIMEOUT_IRQ_MASK, 0x0);
|
||||
|
||||
|
||||
// CRG_TOP
|
||||
REG_SETF(CRG_TOP, BANDGAP_REG, BYPASS_COLD_BOOT_DISABLE, 0x0);
|
||||
REG_SETF(CRG_TOP, BANDGAP_REG, LDO_SLEEP_TRIM, 0x0);
|
||||
REG_SETF(CRG_TOP, BANDGAP_REG, BGR_ITRIM, 0x0);
|
||||
REG_SETF(CRG_TOP, BANDGAP_REG, BGR_TRIM, 0x0);
|
||||
|
||||
REG_SETF(CRG_TOP, BOD_STATUS_REG, BOD_VBAT_LOW, 0x0);
|
||||
REG_SETF(CRG_TOP, BOD_STATUS_REG, BOD_V33_LOW, 0x0);
|
||||
REG_SETF(CRG_TOP, BOD_STATUS_REG, BOD_1V8_FLASH_LOW, 0x0);
|
||||
REG_SETF(CRG_TOP, BOD_STATUS_REG, BOD_1V8_PA_LOW, 0x0);
|
||||
REG_SETF(CRG_TOP, BOD_STATUS_REG, BOD_VDD_LOW, 0x0);
|
||||
|
||||
REG_SETF(CRG_TOP, FORCE_SLEEP_REG, FORCE_BLE_SLEEP, 0x0); // GUESS
|
||||
REG_SETF(CRG_TOP, FORCE_SLEEP_REG, FORCE_FTDF_SLEEP, 0x0); // GUESS
|
||||
|
||||
REG_SETF(CRG_TOP, LDOS_DISABLE_REG, LDOS_DISABLE, 0x0); // GUESS
|
||||
|
||||
REG_SETF(CRG_TOP, AON_SPARE_REG, OSC16_HOLD_AMP_REG, 0x0); // GUESS
|
||||
REG_SETF(CRG_TOP, AON_SPARE_REG, OSC16_SH_DISABLE, 0x0); // GUESS
|
||||
REG_SETF(CRG_TOP, AON_SPARE_REG, EN_BATSYS_RET, 0x0); // GUESS
|
||||
REG_SETF(CRG_TOP, AON_SPARE_REG, EN_BUSSYS_RET, 0x0); // GUESS
|
||||
|
||||
|
||||
// QSPIC
|
||||
REG_SETF(QSPIC, QSPIC_CTRLBUS_REG, QSPIC_DIS_CS, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLBUS_REG, QSPIC_EN_CS, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLBUS_REG, QSPIC_SET_QUAD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLBUS_REG, QSPIC_SET_DUAL, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLBUS_REG, QSPIC_SET_SINGLE, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_USE_32BA, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_FORCENSEQ_EN, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_PCLK_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_RPIPE_EN, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_RXD_NEG, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_HRDY_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_IO3_DAT, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_IO2_DAT, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_IO3_OEN, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_IO2_OEN, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_CLK_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_CTRLMODE_REG, QSPIC_AUTO_MD, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDA_REG, QSPIC_DMY_TX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDA_REG, QSPIC_EXT_TX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDA_REG, QSPIC_ADR_TX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDA_REG, QSPIC_INST_TX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDA_REG, QSPIC_EXT_BYTE, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDA_REG, QSPIC_INST_WB, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDA_REG, QSPIC_INST, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_DMY_FORCE, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_CS_HIGH_MIN, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_WRAP_SIZE, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_WRAP_LEN, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_WRAP_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_INST_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_DMY_NUM, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_EXT_HF_DS, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_EXT_BYTE_EN, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTCMDB_REG, QSPIC_DAT_RX_MD, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_WRITEDATA_REG, QSPIC_WRITEDATA, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_DUMMYDATA_REG, QSPIC_DUMMYDATA, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_ERASECTRL_REG, QSPIC_ERASE_EN, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECTRL_REG, QSPIC_ERS_ADDR, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDA_REG, QSPIC_RES_INST, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDA_REG, QSPIC_SUS_INST, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDA_REG, QSPIC_WEN_INST, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDA_REG, QSPIC_ERS_INST, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDB_REG, QSPIC_RESSUS_DLY, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDB_REG, QSPIC_ERSRES_HLD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDB_REG, QSPIC_ERS_CS_HI, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDB_REG, QSPIC_EAD_TX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDB_REG, QSPIC_RES_TX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDB_REG, QSPIC_SUS_TX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDB_REG, QSPIC_WEN_TX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_ERASECMDB_REG, QSPIC_ERS_TX_MD, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_BURSTBRK_REG, QSPIC_SEC_HF_DS, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTBRK_REG, QSPIC_BRK_TX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTBRK_REG, QSPIC_BRK_SZ, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTBRK_REG, QSPIC_BRK_EN, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_BURSTBRK_REG, QSPIC_BRK_WRD, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_STATUSCMD_REG, QSPIC_STSDLY_SEL, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_STATUSCMD_REG, QSPIC_RESSTS_DLY, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_STATUSCMD_REG, QSPIC_BUSY_VAL, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_STATUSCMD_REG, QSPIC_RSTAT_RX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_STATUSCMD_REG, QSPIC_RSTAT_TX_MD, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_STATUSCMD_REG, QSPIC_RSTAT_INST, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_CHCKERASE_REG, QSPIC_CHCKERASE, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_GP_REG, QSPIC_PADS_SLEW, 0x0);
|
||||
REG_SETF(QSPIC, QSPIC_GP_REG, QSPIC_PADS_DRV, 0x0);
|
||||
|
||||
REG_SETF(QSPIC, QSPIC_UCODE_START, QSPIC_UCODE_X, 0x0);
|
||||
|
||||
|
||||
// GPREG
|
||||
REG_SETF(GPREG, PLL_SYS_CTRL1_REG, PLL_R_DIV, 0x1);
|
||||
REG_SETF(GPREG, PLL_SYS_CTRL1_REG, LDO_PLL_VREF_HOLD, 0x0);
|
||||
REG_SETF(GPREG, PLL_SYS_CTRL1_REG, LDO_PLL_ENABLE, 0x0);
|
||||
REG_SETF(GPREG, PLL_SYS_CTRL1_REG, PLL_EN, 0x0);
|
||||
|
||||
REG_SETF(GPREG, PLL_SYS_CTRL2_REG, PLL_SEL_MIN_CUR_INT, 0x0);
|
||||
REG_SETF(GPREG, PLL_SYS_CTRL2_REG, PLL_DEL_SEL, 0x2);
|
||||
REG_SETF(GPREG, PLL_SYS_CTRL2_REG, PLL_N_DIV, 0x6);
|
||||
|
||||
REG_SETF(GPREG, PLL_SYS_CTRL3_REG, PLL_RECALIB, 0x0); // GUESS
|
||||
REG_SETF(GPREG, PLL_SYS_CTRL3_REG, PLL_START_DEL, 0xF);
|
||||
REG_SETF(GPREG, PLL_SYS_CTRL3_REG, PLL_ICP_SEL, 0x9);
|
||||
|
||||
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_LOCK_DET_RES_CNT, 0x0);
|
||||
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_SEL_R_DIV_TEST, 0x0);
|
||||
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_SEL_N_DIV_TEST, 0x0);
|
||||
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_CHANGE, 0x0);
|
||||
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_OPEN_LOOP, 0x0);
|
||||
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_TEST_VCTR, 0x0);
|
||||
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_MIN_CURRENT, 0x38);
|
||||
REG_SETF(GPREG, PLL_SYS_TEST_REG, PLL_DIS_LOOPFILT, 0x0);
|
||||
|
||||
|
||||
// CACHE
|
||||
REG_SETF(CACHE, CACHE_CTRL1_REG, CACHE_RES1, 0x0);
|
||||
REG_SETF(CACHE, CACHE_CTRL1_REG, CACHE_FLUSH, 0x0);
|
||||
|
||||
REG_SETF(CACHE, CACHE_LNSIZECFG_REG, CACHE_LINE, 0x0);
|
||||
|
||||
REG_SETF(CACHE, CACHE_ASSOCCFG_REG, CACHE_ASSOC, 0x2);
|
||||
|
||||
REG_SETF(CACHE, CACHE_CTRL2_REG, ENABLE_ALSO_QSPIFLASH_CACHED, 0x0);
|
||||
REG_SETF(CACHE, CACHE_CTRL2_REG, ENABLE_ALSO_OTP_CACHED, 0x0);
|
||||
REG_SETF(CACHE, CACHE_CTRL2_REG, CACHE_CGEN, 0x0);
|
||||
REG_SETF(CACHE, CACHE_CTRL2_REG, CACHE_WEN, 0x0);
|
||||
REG_SETF(CACHE, CACHE_CTRL2_REG, CACHE_LEN, 0x0);
|
||||
|
||||
REG_SETF(CACHE, CACHE_CTRL3_REG, CACHE_CONTROLLER_RESET, 0x0);
|
||||
REG_SETF(CACHE, CACHE_CTRL3_REG, CACHE_RAM_SIZE_RESET_VALUE, 0x2);
|
||||
REG_SETF(CACHE, CACHE_CTRL3_REG, CACHE_LINE_SIZE_RESET_VALUE, 0x0);
|
||||
REG_SETF(CACHE, CACHE_CTRL3_REG, CACHE_ASSOCIATIVITY_RESET_VALUE, 0x2);
|
||||
|
||||
REG_SETF(CACHE, CACHE_MRM_HITS_REG, MRM_HITS, 0x0);
|
||||
|
||||
REG_SETF(CACHE, CACHE_MRM_MISSES_REG, MRM_MISSES, 0x0);
|
||||
|
||||
REG_SETF(CACHE, CACHE_MRM_CTRL_REG, MRM_IRQ_THRES_STATUS, 0x0);
|
||||
REG_SETF(CACHE, CACHE_MRM_CTRL_REG, MRM_IRQ_TINT_STATUS, 0x0);
|
||||
REG_SETF(CACHE, CACHE_MRM_CTRL_REG, MRM_IRQ_MASK, 0x0);
|
||||
REG_SETF(CACHE, CACHE_MRM_CTRL_REG, MRM_START, 0x0);
|
||||
|
||||
REG_SETF(CACHE, CACHE_MRM_TINT_REG, MRM_TINT, 0x0);
|
||||
|
||||
REG_SETF(CACHE, CACHE_MRM_THRES_REG, MRM_THRES, 0x0);
|
||||
|
||||
REG_SETF(CACHE, SWD_RESET_REG, SWD_HW_RESET_REQ, 0x0);
|
||||
|
||||
// DCDC
|
||||
ALL_REGISTERS.DCDC_CTRL_0_REG = DCDC->DCDC_CTRL_0_REG;
|
||||
ALL_REGISTERS.DCDC_CTRL_1_REG = DCDC->DCDC_CTRL_1_REG;
|
||||
ALL_REGISTERS.DCDC_CTRL_2_REG = DCDC->DCDC_CTRL_2_REG;
|
||||
ALL_REGISTERS.DCDC_V14_0_REG = DCDC->DCDC_V14_0_REG;
|
||||
ALL_REGISTERS.DCDC_V14_1_REG = DCDC->DCDC_V14_1_REG;
|
||||
ALL_REGISTERS.DCDC_V18_0_REG = DCDC->DCDC_V18_0_REG;
|
||||
ALL_REGISTERS.DCDC_V18_1_REG = DCDC->DCDC_V18_1_REG;
|
||||
ALL_REGISTERS.DCDC_VDD_0_REG = DCDC->DCDC_VDD_0_REG;
|
||||
ALL_REGISTERS.DCDC_VDD_1_REG = DCDC->DCDC_VDD_1_REG;
|
||||
ALL_REGISTERS.DCDC_V18P_0_REG = DCDC->DCDC_V18P_0_REG;
|
||||
ALL_REGISTERS.DCDC_V18P_1_REG = DCDC->DCDC_V18P_1_REG;
|
||||
ALL_REGISTERS.DCDC_RET_0_REG = DCDC->DCDC_RET_0_REG;
|
||||
ALL_REGISTERS.DCDC_RET_1_REG = DCDC->DCDC_RET_1_REG;
|
||||
ALL_REGISTERS.DCDC_TRIM_REG = DCDC->DCDC_TRIM_REG;
|
||||
ALL_REGISTERS.DCDC_TEST_0_REG = DCDC->DCDC_TEST_0_REG;
|
||||
ALL_REGISTERS.DCDC_TEST_1_REG = DCDC->DCDC_TEST_1_REG;
|
||||
|
||||
ALL_REGISTERS.DCDC_IRQ_CLEAR_REG = DCDC->DCDC_IRQ_CLEAR_REG;
|
||||
ALL_REGISTERS.DCDC_IRQ_MASK_REG = DCDC->DCDC_IRQ_MASK_REG;
|
||||
|
||||
// CRG_TOP
|
||||
ALL_REGISTERS.BANDGAP_REG = CRG_TOP->BANDGAP_REG;
|
||||
ALL_REGISTERS.BOD_STATUS_REG = CRG_TOP->BOD_STATUS_REG;
|
||||
ALL_REGISTERS.FORCE_SLEEP_REG = CRG_TOP->FORCE_SLEEP_REG;
|
||||
ALL_REGISTERS.LDOS_DISABLE_REG = CRG_TOP->LDOS_DISABLE_REG;
|
||||
ALL_REGISTERS.AON_SPARE_REG = CRG_TOP->AON_SPARE_REG;
|
||||
|
||||
// QSPIC
|
||||
ALL_REGISTERS.QSPIC_CTRLMODE_REG = QSPIC->QSPIC_CTRLMODE_REG;
|
||||
ALL_REGISTERS.QSPIC_BURSTCMDA_REG = QSPIC->QSPIC_BURSTCMDA_REG;
|
||||
ALL_REGISTERS.QSPIC_BURSTCMDB_REG = QSPIC->QSPIC_BURSTCMDB_REG;
|
||||
ALL_REGISTERS.QSPIC_WRITEDATA_REG = QSPIC->QSPIC_WRITEDATA_REG;
|
||||
ALL_REGISTERS.QSPIC_DUMMYDATA_REG = QSPIC->QSPIC_DUMMYDATA_REG;
|
||||
ALL_REGISTERS.QSPIC_ERASECTRL_REG = QSPIC->QSPIC_ERASECTRL_REG;
|
||||
ALL_REGISTERS.QSPIC_ERASECMDA_REG = QSPIC->QSPIC_ERASECMDA_REG;
|
||||
ALL_REGISTERS.QSPIC_ERASECMDB_REG = QSPIC->QSPIC_ERASECMDB_REG;
|
||||
ALL_REGISTERS.QSPIC_BURSTBRK_REG = QSPIC->QSPIC_BURSTBRK_REG;
|
||||
ALL_REGISTERS.QSPIC_STATUSCMD_REG = QSPIC->QSPIC_STATUSCMD_REG;
|
||||
ALL_REGISTERS.QSPIC_CHCKERASE_REG = QSPIC->QSPIC_CHCKERASE_REG;
|
||||
ALL_REGISTERS.QSPIC_GP_REG = QSPIC->QSPIC_GP_REG;
|
||||
ALL_REGISTERS.QSPIC_UCODE_START = QSPIC->QSPIC_UCODE_START;
|
||||
|
||||
// GPREG
|
||||
ALL_REGISTERS.PLL_SYS_CTRL1_REG = GPREG->PLL_SYS_CTRL1_REG;
|
||||
ALL_REGISTERS.PLL_SYS_CTRL2_REG = GPREG->PLL_SYS_CTRL2_REG;
|
||||
ALL_REGISTERS.PLL_SYS_CTRL3_REG = GPREG->PLL_SYS_CTRL3_REG;
|
||||
ALL_REGISTERS.PLL_SYS_TEST_REG = GPREG->PLL_SYS_TEST_REG;
|
||||
|
||||
// CACHE
|
||||
ALL_REGISTERS.CACHE_CTRL1_REG = CACHE->CACHE_CTRL1_REG;
|
||||
ALL_REGISTERS.CACHE_LNSIZECFG_REG = CACHE->CACHE_LNSIZECFG_REG;
|
||||
ALL_REGISTERS.CACHE_ASSOCCFG_REG = CACHE->CACHE_ASSOCCFG_REG;
|
||||
ALL_REGISTERS.CACHE_CTRL2_REG = CACHE->CACHE_CTRL2_REG;
|
||||
ALL_REGISTERS.CACHE_CTRL3_REG = CACHE->CACHE_CTRL3_REG;
|
||||
ALL_REGISTERS.CACHE_MRM_HITS_REG = CACHE->CACHE_MRM_HITS_REG;
|
||||
ALL_REGISTERS.CACHE_MRM_MISSES_REG = CACHE->CACHE_MRM_MISSES_REG;
|
||||
ALL_REGISTERS.CACHE_MRM_CTRL_REG = CACHE->CACHE_MRM_CTRL_REG;
|
||||
ALL_REGISTERS.CACHE_MRM_TINT_REG = CACHE->CACHE_MRM_TINT_REG;
|
||||
ALL_REGISTERS.CACHE_MRM_THRES_REG = CACHE->CACHE_MRM_THRES_REG;
|
||||
ALL_REGISTERS.SWD_RESET_REG = CACHE->SWD_RESET_REG;
|
||||
|
||||
#endif // DEFAULT_REGISTER_DEBUG
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "debug_print.h"
|
||||
#include "hw_watchdog.h"
|
||||
#include "sdk_defs.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
static void prv_handle_fault(void) {
|
||||
#if NO_WATCHDOG
|
||||
while (1) {};
|
||||
#else
|
||||
NVIC_SystemReset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void HardFault_HandlerC(uint32_t *fault_args) {
|
||||
debug_print_str("Hard fault");
|
||||
prv_handle_fault();
|
||||
}
|
||||
|
||||
void UsageFault_HandlerC(uint32_t *fault_args) {
|
||||
debug_print_str("Usage fault");
|
||||
prv_handle_fault();
|
||||
}
|
||||
|
||||
void BusFault_HandlerC(uint32_t *fault_args) {
|
||||
debug_print_str("Bus fault");
|
||||
prv_handle_fault();
|
||||
}
|
||||
|
||||
void MemManag_HandlerC(uint32_t *fault_args) {
|
||||
debug_print_str("MemManag fault");
|
||||
prv_handle_fault();
|
||||
}
|
||||
|
||||
void NMI_HandlerC(uint32_t *fault_args) {
|
||||
debug_print_str("NMI Handler");
|
||||
prv_handle_fault();
|
||||
}
|
||||
207
src/bluetooth-fw/da1468x/controller/boot/src/host_transport.c
Normal file
207
src/bluetooth-fw/da1468x/controller/boot/src/host_transport.c
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "da1468x_mem_map.h"
|
||||
|
||||
#include "debug_print.h"
|
||||
#include "hw_gpio.h"
|
||||
#include "hw_spi.h"
|
||||
|
||||
#include "board.h"
|
||||
#include "host_transport.h"
|
||||
#include "util/crc32.h"
|
||||
|
||||
// Dialog SPI bootloader implementation
|
||||
//
|
||||
// See following doc for protocol specification:
|
||||
// https://docs.google.com/document/d/1PrnTsDhBZYsrlxa9-6OzdoEvtE50uVkSTufqEdQ2yWw/
|
||||
|
||||
// The arm vector table has a default size of 0x40 bytes. The rest of the space
|
||||
// is variable depending on the number of IRQn interrupt handlers implemented
|
||||
// by the platform. For the dialog part 32 IRQs are provided. There is also a
|
||||
// patch area used by the dialog BT ROM which must be loaded and comes directly
|
||||
// after the vector table, it's 128 bytes
|
||||
#define IVT_TABLE_SIZE (0x40 + 32 * 4 + 0x80)
|
||||
static uint8_t s_vector_table[IVT_TABLE_SIZE];
|
||||
|
||||
static volatile bool s_expected_bytes_received = false;
|
||||
static void prv_expect_byte_spi_int_cb(void *user_data, uint16_t transferred) {
|
||||
s_expected_bytes_received = true;
|
||||
debug_print_str_and_int("Bytes TX/RXed: ", transferred);
|
||||
}
|
||||
|
||||
// Interesting observation: The INT fires on writes once the data has been drained to the FIFO,
|
||||
// not when it actually gets drained.
|
||||
static void prv_write_or_read_bytes(void *byte_buffer, int num_bytes, bool do_write) {
|
||||
s_expected_bytes_received = false;
|
||||
if (do_write) {
|
||||
hw_spi_write_buf(HOST_SPI->spi.peripheral,
|
||||
byte_buffer, num_bytes, prv_expect_byte_spi_int_cb, NULL);
|
||||
} else {
|
||||
hw_spi_read_buf(HOST_SPI->spi.peripheral,
|
||||
byte_buffer, num_bytes, prv_expect_byte_spi_int_cb, NULL);
|
||||
}
|
||||
|
||||
hw_gpio_set_active(HOST_SPI->mcu_int.port, HOST_SPI->mcu_int.pin);
|
||||
// Probably not necessary but add a little delay so its easier to catch INT
|
||||
// on logic analyzer
|
||||
for (volatile int delay = 0; delay < 50; delay++) { }
|
||||
|
||||
while (!s_expected_bytes_received) { };
|
||||
hw_gpio_set_inactive(HOST_SPI->mcu_int.port, HOST_SPI->mcu_int.pin);
|
||||
}
|
||||
|
||||
static void prv_handle_hi_command(void) {
|
||||
debug_print_str("HI CMD\n");
|
||||
uint8_t response[] = { 'H', 'E', 'R', 'E' };
|
||||
prv_write_or_read_bytes(response, sizeof(response), true);
|
||||
}
|
||||
|
||||
static void prv_send_crc_of_mem_region(void *data_start, size_t len) {
|
||||
uint32_t crc = CRC32_INIT;
|
||||
crc = crc32(crc, data_start, len);
|
||||
|
||||
prv_write_or_read_bytes((uint8_t *)&crc, sizeof(crc), true);
|
||||
debug_print_str_and_int("Computed CRC: ", (int)crc);
|
||||
}
|
||||
|
||||
static void prv_handle_load_data_command(void) {
|
||||
debug_print_str("LD CMD\n");
|
||||
|
||||
struct __attribute__((packed)) {
|
||||
uint32_t copy_address;
|
||||
uint32_t length;
|
||||
} send_data_cmd_payload = { };
|
||||
|
||||
prv_write_or_read_bytes(&send_data_cmd_payload, sizeof(send_data_cmd_payload), false);
|
||||
|
||||
debug_print_str_and_int(" Address:", send_data_cmd_payload.copy_address);
|
||||
debug_print_str_and_int(" Length:", send_data_cmd_payload.length);
|
||||
|
||||
prv_write_or_read_bytes((uint8_t*)send_data_cmd_payload.copy_address,
|
||||
send_data_cmd_payload.length, false);
|
||||
|
||||
prv_send_crc_of_mem_region(
|
||||
(void *)send_data_cmd_payload.copy_address, send_data_cmd_payload.length);
|
||||
}
|
||||
|
||||
static void prv_handle_vector_table_update_command(void) {
|
||||
debug_print_str("VT CMD\n");
|
||||
|
||||
// reset vector table
|
||||
memset(s_vector_table, 0x0, sizeof(s_vector_table));
|
||||
|
||||
uint8_t number_of_entries = 0;
|
||||
prv_write_or_read_bytes(&number_of_entries, sizeof(number_of_entries), false);
|
||||
|
||||
size_t vector_table_copy_size = number_of_entries * 4;
|
||||
prv_write_or_read_bytes(s_vector_table, vector_table_copy_size, false);
|
||||
|
||||
prv_send_crc_of_mem_region(&s_vector_table[0], vector_table_copy_size);
|
||||
}
|
||||
|
||||
static void prv_handle_reboot_command(void) {
|
||||
debug_print_str("RT CMD\n");
|
||||
const uint32_t vt_start_addr = DATA_RAM_BASE_ADDRESS;
|
||||
|
||||
// We are about to overwrite the vector table. Disable interrupts while
|
||||
// this is taking place
|
||||
__disable_irq();
|
||||
|
||||
// Interrupt Clear Enable Register:
|
||||
NVIC->ICER[0] = ~0;
|
||||
// Interrupt Clear Pending Register:
|
||||
NVIC->ICPR[0] = ~0;
|
||||
|
||||
for (size_t i = 0; i < sizeof(s_vector_table); i++) {
|
||||
*(uint8_t *)(vt_start_addr + i) = s_vector_table[i];
|
||||
}
|
||||
|
||||
NVIC_SystemReset();
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
static void prv_bootloader_loop(void) {
|
||||
debug_print_str("Beginning Bootloader Loop\n");
|
||||
while (1) {
|
||||
uint8_t cmd[2] = { };
|
||||
prv_write_or_read_bytes(cmd, sizeof(cmd), false);
|
||||
|
||||
if (cmd[0] == 'H' && cmd[1] == 'I') {
|
||||
prv_handle_hi_command();
|
||||
} else if (cmd[0] == 'L' && cmd[1] == 'D') {
|
||||
prv_handle_load_data_command();
|
||||
} else if (cmd[0] == 'V' && cmd[1] == 'T') {
|
||||
prv_handle_vector_table_update_command();
|
||||
} else if (cmd[0] == 'R' && cmd[1] == 'T') {
|
||||
prv_handle_reboot_command();
|
||||
} else {
|
||||
debug_print_str("Unknown CMD:");
|
||||
debug_print_str_and_int(" Byte 0:", cmd[0]);
|
||||
debug_print_str_and_int(" Byte 1:", cmd[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void prv_configure_pins_for_spi_transfer(void) {
|
||||
hw_gpio_set_pin_function(HOST_SPI->spi.cs.port, HOST_SPI->spi.cs.pin,
|
||||
HW_GPIO_MODE_INPUT, HOST_SPI->spi.cs.function);
|
||||
hw_gpio_set_pin_function(HOST_SPI->spi.cs_2.port, HOST_SPI->spi.cs_2.pin,
|
||||
HW_GPIO_MODE_INPUT, HOST_SPI->spi.cs_2.function);
|
||||
hw_gpio_set_pin_function(HOST_SPI->spi.clk.port, HOST_SPI->spi.clk.pin,
|
||||
HW_GPIO_MODE_INPUT, HOST_SPI->spi.clk.function);
|
||||
hw_gpio_set_pin_function(HOST_SPI->spi.mosi_di.port, HOST_SPI->spi.mosi_di.pin,
|
||||
HW_GPIO_MODE_INPUT, HOST_SPI->spi.mosi_di.function);
|
||||
hw_gpio_set_pin_function(HOST_SPI->spi.miso_do.port, HOST_SPI->spi.miso_do.pin,
|
||||
HW_GPIO_MODE_INPUT, HOST_SPI->spi.miso_do.function);
|
||||
|
||||
hw_gpio_configure_pin(HOST_SPI->mcu_int.port, HOST_SPI->mcu_int.pin,
|
||||
HW_GPIO_MODE_OUTPUT, HOST_SPI->mcu_int.function, false);
|
||||
}
|
||||
|
||||
static void prv_configure_spi_peripheral(void) {
|
||||
spi_config config = {
|
||||
.cs_pad = { 0, 0 },
|
||||
.word_mode = HW_SPI_WORD_8BIT,
|
||||
.smn_role = HW_SPI_MODE_SLAVE,
|
||||
.phase_mode = HW_SPI_PHA_MODE_0,
|
||||
.polarity_mode = HW_SPI_POL_LOW,
|
||||
.mint_mode = HW_SPI_MINT_DISABLE, // we are not using this feature
|
||||
.xtal_freq = 0,
|
||||
.fifo_mode = HW_SPI_FIFO_RX_TX,
|
||||
.disabled = 0,
|
||||
#ifdef HW_SPI_DMA_SUPPORT
|
||||
.use_dma = 1,
|
||||
.rx_dma_channel = HOST_SPI_RX_DMA_CHANNEL,
|
||||
.tx_dma_channel = HOST_SPI_TX_DMA_CHANNEL,
|
||||
#endif
|
||||
};
|
||||
|
||||
hw_spi_init(HOST_SPI->spi.peripheral, &config);
|
||||
}
|
||||
|
||||
void host_transport_begin(void) {
|
||||
prv_configure_pins_for_spi_transfer();
|
||||
|
||||
prv_configure_spi_peripheral();
|
||||
|
||||
prv_bootloader_loop();
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
36
src/bluetooth-fw/da1468x/controller/boot/src/passert.c
Normal file
36
src/bluetooth-fw/da1468x/controller/boot/src/passert.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <util/attributes.h>
|
||||
|
||||
#include "debug_print.h"
|
||||
|
||||
#include "sdk_defs.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//! Implementation for the bootloader.
|
||||
//! Because ASSERT_ERROR() and ASSERT_WARNING() macros in sdk_defs.h use this function,
|
||||
//! we need an implementation for the bootloader as well.
|
||||
NORETURN passert_failed_no_message(void) {
|
||||
debug_print_str_and_int("ASRT", (int)__builtin_return_address(0));
|
||||
#if NO_WATCHDOG
|
||||
while (1) {};
|
||||
#else
|
||||
NVIC_SystemReset();
|
||||
#endif
|
||||
__builtin_unreachable();
|
||||
}
|
||||
79
src/bluetooth-fw/da1468x/controller/boot/wscript
Normal file
79
src/bluetooth-fw/da1468x/controller/boot/wscript
Normal file
@@ -0,0 +1,79 @@
|
||||
import sys
|
||||
|
||||
import waftools.objcopy
|
||||
|
||||
from resources.types.resource_definition import ResourceDefinition
|
||||
from resources.types.resource_object import ResourceObject
|
||||
|
||||
CUSTOM_CONFIG_H_PATH = 'config/custom_config_boot.h'
|
||||
|
||||
|
||||
def build(bld):
|
||||
bld.env.append_value('DEFINES', ['BLE_BOOTLOADER=1'])
|
||||
|
||||
sys.path.append(bld.path.find_node('../..').abspath())
|
||||
from dialog_waf import get_sdk_node, collect_sdk_sources, generate_mem_ld
|
||||
|
||||
mem_ld_node = generate_mem_ld(bld, CUSTOM_CONFIG_H_PATH)
|
||||
|
||||
# Collect source files:
|
||||
source_dirs = ['src', '../common/src']
|
||||
sources = sum([bld.path.ant_glob('%s/**/*.c' % d)
|
||||
for d in source_dirs], [])
|
||||
sdk_sources = [
|
||||
'sdk/bsp/startup/vector_table.S',
|
||||
'sdk/bsp/startup/startup_ARMCM0.S',
|
||||
'sdk/bsp/startup/system_ARMCM0.c',
|
||||
'sdk/bsp/startup/config.c',
|
||||
'sdk/bsp/peripherals/src/hw_cpm.c',
|
||||
'sdk/bsp/peripherals/src/hw_dma.c',
|
||||
'sdk/bsp/peripherals/src/hw_gpio.c',
|
||||
'sdk/bsp/peripherals/src/hw_spi.c',
|
||||
'sdk/bsp/peripherals/src/hw_uart.c',
|
||||
'sdk/bsp/peripherals/src/hw_watchdog.c',
|
||||
|
||||
# Used by system_ARMCM0.c:
|
||||
'sdk/bsp/peripherals/src/hw_otpc.c',
|
||||
'sdk/bsp/peripherals/src/sys_tcs.c',
|
||||
]
|
||||
sources.extend(collect_sdk_sources(bld, sdk_sources))
|
||||
|
||||
linkflags = ['-Wl,-Map,bt_da14681_boot.map',
|
||||
'-Wl,--build-id=sha1']
|
||||
|
||||
# Includes:
|
||||
includes = ['include', '../common/include', '../../include', 'config']
|
||||
elf_node = bld.path.get_bld().make_node('bt_da14681_boot.elf')
|
||||
bld.program(features='c asm cprogram',
|
||||
source=sources,
|
||||
includes=includes,
|
||||
target=elf_node,
|
||||
lib=['gcc'],
|
||||
linkflags=linkflags,
|
||||
ldscript=mem_ld_node,
|
||||
inject_include_files=[CUSTOM_CONFIG_H_PATH],
|
||||
use=['dialog_sdk_includes', 'dialog_board_boot',
|
||||
'pblibc-cm0', 'libutil_includes', 'libutil-cm0'])
|
||||
|
||||
bld.add_manual_dependency(elf_node, mem_ld_node)
|
||||
|
||||
bin_node = elf_node.change_ext('.bin')
|
||||
bld(rule=waftools.objcopy.objcopy_bin, source=elf_node, target=bin_node)
|
||||
|
||||
def create_bt_patch_resource(task):
|
||||
bin_data = task.inputs[0].read('rb')
|
||||
reso = ResourceObject(ResourceDefinition('raw', 'BT_BOOT_IMAGE', None,
|
||||
storage=task.generator.storage), bin_data)
|
||||
reso.dump(task.outputs[0])
|
||||
|
||||
reso_node = elf_node.change_ext('.bin.reso')
|
||||
bld(rule=create_bt_patch_resource, source=bin_node, target=reso_node,
|
||||
storage=bld.get_bluetooth_fw_storage())
|
||||
|
||||
bld.DYNAMIC_RESOURCES.append(reso_node)
|
||||
|
||||
def configure(ctx):
|
||||
pass
|
||||
|
||||
|
||||
# vim:filetype=python
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ad_gpadc.h>
|
||||
#include <ad_i2c.h>
|
||||
#include <ad_spi.h>
|
||||
#include <ad_uart.h>
|
||||
|
||||
#include "board.h"
|
||||
|
||||
SPI_BUS(SPI1)
|
||||
SPI_SLAVE_TO_EXT_MASTER(SPI1, PEBBLE_HOST, CONFIG_SPI_IGNORE_CS,
|
||||
CONFIG_SPI_WORD_MODE, CONFIG_SPI_POL_MODE,
|
||||
CONFIG_SPI_PHASE_MODE, CONFIG_SPI_DMA_CHANNEL);
|
||||
SPI_BUS_END
|
||||
|
||||
#if dg_configGPADC_ADAPTER
|
||||
|
||||
/*
|
||||
* Define sources connected to GPADC
|
||||
*/
|
||||
|
||||
GPADC_SOURCE(TEMP_SENSOR, HW_GPADC_CLOCK_INTERNAL, HW_GPADC_INPUT_MODE_SINGLE_ENDED,
|
||||
HW_GPADC_INPUT_SE_TEMPSENS, 5, false, HW_GPADC_OVERSAMPLING_1_SAMPLE,
|
||||
HW_GPADC_INPUT_VOLTAGE_UP_TO_1V2)
|
||||
|
||||
#endif /* dg_configGPADC_ADAPTER */
|
||||
0
src/bluetooth-fw/da1468x/controller/main/include/.gitignore
vendored
Normal file
0
src/bluetooth-fw/da1468x/controller/main/include/.gitignore
vendored
Normal file
43
src/bluetooth-fw/da1468x/controller/main/include/advert.h
Normal file
43
src/bluetooth-fw/da1468x/controller/main/include/advert.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "advert_state.h"
|
||||
|
||||
// Dialog SDK:
|
||||
#include "ble_common.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct ble_evt_gap_adv_completed ble_evt_gap_adv_completed_t;
|
||||
typedef struct BLEAdData BLEAdData;
|
||||
|
||||
ble_error_t advert_set_interval(uint16_t min_slots, uint16_t max_slots);
|
||||
|
||||
//! @return The current state, returned for debugging/logging purposes.
|
||||
//! It's possible this is not AdvertState_Running, in case advertising was paused or is still
|
||||
//! stopping.
|
||||
AdvertState advert_enable(void);
|
||||
|
||||
void advert_set_data(const BLEAdData *ad_data);
|
||||
|
||||
void advert_disable(void);
|
||||
|
||||
void advert_handle_completed(const ble_evt_gap_adv_completed_t *evt);
|
||||
|
||||
void advert_init(void);
|
||||
27
src/bluetooth-fw/da1468x/controller/main/include/aes.h
Normal file
27
src/bluetooth-fw/da1468x/controller/main/include/aes.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define AES_128_BLOCK_SIZE (16)
|
||||
#define AES_128_KEY_SIZE (16)
|
||||
|
||||
bool aes_128_encrypt_block(const uint8_t key[AES_128_KEY_SIZE],
|
||||
const uint8_t plain_text_block[AES_128_BLOCK_SIZE],
|
||||
uint8_t cipher_text_block_out[AES_128_BLOCK_SIZE]);
|
||||
26
src/bluetooth-fw/da1468x/controller/main/include/ble_task.h
Normal file
26
src/bluetooth-fw/da1468x/controller/main/include/ble_task.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <bluetooth/init.h>
|
||||
|
||||
void ble_task_assert_is_executing_on_ble_task(void);
|
||||
|
||||
//! Start the Dialog BLE stack with the given config and block until it's up and running.
|
||||
void ble_task_init(const BTDriverConfig *config);
|
||||
23
src/bluetooth-fw/da1468x/controller/main/include/chip_id.h
Normal file
23
src/bluetooth-fw/da1468x/controller/main/include/chip_id.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "dialog_chip_id.h"
|
||||
#include "util/attributes.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
bool dialog_chip_id_copy(DialogChipID *chip_id_out);
|
||||
112
src/bluetooth-fw/da1468x/controller/main/include/connection.h
Normal file
112
src/bluetooth-fw/da1468x/controller/main/include/connection.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gatt_wrapper_types.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct Connection Connection;
|
||||
typedef struct BTDeviceInternal BTDeviceInternal;
|
||||
typedef struct BTDeviceAddress BTDeviceAddress;
|
||||
typedef struct BleConnectionParams BleConnectionParams;
|
||||
typedef struct PPoGATTWorkAroundState PPoGATTWorkAroundState;
|
||||
typedef void (*ConnectionForEachCallback)(Connection *connection, void *data);
|
||||
|
||||
// Call once on boot before doing anything with Bluetooth
|
||||
void connection_module_init(void);
|
||||
|
||||
// Call every time a BT connection is created/destroyed. These ops should
|
||||
// be driven from events received by the ble_task
|
||||
//! @param initial_addr The remote address at the time of connection establishment. See notes
|
||||
//! with the initial_addr field in the Connection struct.
|
||||
//! @param local_addr The local/own address that was used to advertise at the time of connection
|
||||
//! establishment.
|
||||
Connection *connection_create(uint16_t conn_idx, const BTDeviceInternal *initial_addr,
|
||||
const BTDeviceAddress *local_addr, const BleConnectionParams *params);
|
||||
void connection_destroy(Connection *connection);
|
||||
|
||||
// Returns true if the pointer given is in our list of connections
|
||||
bool connection_is_valid(Connection *connection);
|
||||
|
||||
// Enqueues a Gatt Operation to the list of outstanding Gatt Operations in the Connection object.
|
||||
void connection_enqueue_gatt_op(Connection *connection, uintptr_t context_ref,
|
||||
GattRespDest resp_dest, GattOpType op_type);
|
||||
// Dequeues a Gatt Operation from the list of outstanding Gatt Operations in the Connection object.
|
||||
// Returns true if the object was successfully dequeued and false if there are no operations known
|
||||
// to be in progress
|
||||
bool connection_dequeue_gatt_op(Connection *connection, uintptr_t *context_ref,
|
||||
GattRespDest *resp_dest, GattOpType expected_op_type);
|
||||
// Pops the most recent Gatt Operation appended to the list.
|
||||
bool connection_pop_gatt_op(Connection *connection);
|
||||
|
||||
//
|
||||
// Retrieve Connections
|
||||
//
|
||||
|
||||
Connection *connection_by_idx(uint16_t conn_idx);
|
||||
Connection *connection_by_idx_check(uint16_t conn_idx);
|
||||
Connection *connection_by_address(const BTDeviceInternal *addr_buf);
|
||||
Connection *connection_by_address_check(const BTDeviceInternal *addr_out);
|
||||
|
||||
// @note: internal lock will be held for the duration of this call
|
||||
void connection_for_each(ConnectionForEachCallback cb, void *data);
|
||||
|
||||
//
|
||||
// Getters
|
||||
//
|
||||
|
||||
uint16_t connection_get_idx(Connection *connection);
|
||||
//! If valid, gets the updated_addr of the connection, or otherwise the initial_addr.
|
||||
void connection_get_address(const Connection *connection, BTDeviceInternal *addr_buf);
|
||||
//! Gets the local/own address that was used to advertise at the time of connection establishment.
|
||||
void connection_get_local_address(Connection *connection, BTDeviceAddress *addr_buf);
|
||||
void connection_get_address_by_idx_check(uint16_t conn_idx, BTDeviceInternal *addr_out);
|
||||
void connection_get_conn_params(const Connection *connection,
|
||||
BleConnectionParams *params_out);
|
||||
bool connection_is_subscribed_to_gatt_mtu_notifications(const Connection *connection);
|
||||
bool connection_is_gateway(Connection *connection);
|
||||
bool connection_is_subscribed_to_connection_status_notifications(const Connection *connection);
|
||||
bool connection_is_subscribed_to_conn_param_notifications(const Connection *connection);
|
||||
bool connection_should_pin_address(const Connection *connection);
|
||||
bool connection_should_auto_accept_re_pairing(const Connection *connection);
|
||||
bool connection_is_reversed_ppogatt_enabled(const Connection *connection);
|
||||
uint8_t connection_get_last_pairing_result(uint16_t conn_idx);
|
||||
PPoGATTWorkAroundState *connection_get_ppogatt_wa_state(Connection *connection);
|
||||
|
||||
//
|
||||
// Setters - Sets the requested value provided connection_is_valid(connection) returns true
|
||||
//
|
||||
|
||||
void connection_set_gateway(Connection *connection, bool is_gateway);
|
||||
void connection_set_subscribed_to_connection_status_notifications(
|
||||
Connection *connection, bool is_subscribed);
|
||||
void connection_set_subscribed_to_gatt_mtu_notifications(
|
||||
Connection *connection, bool is_subscribed);
|
||||
void connection_set_subscribed_to_conn_param_notifications(
|
||||
Connection *connection, bool is_subscribed);
|
||||
void connection_set_conn_params(Connection *connection, const BleConnectionParams *params);
|
||||
|
||||
void connection_update_address(Connection *connection, const BTDeviceInternal *updated_addr);
|
||||
void connection_set_should_pin_address(Connection *connection, bool should_pin_address);
|
||||
void connection_set_should_auto_accept_re_pairing(Connection *connection,
|
||||
bool should_auto_accept_re_pairing);
|
||||
void connection_set_reversed_ppogatt_enabled(Connection *connection,
|
||||
bool is_reversed_ppogatt_enabled);
|
||||
void connection_set_last_pairing_result(uint16_t conn_idx, uint8_t result);
|
||||
void connection_set_ppogatt_wa_state(Connection *connection, PPoGATTWorkAroundState *state);
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "connection.h"
|
||||
|
||||
#include <bluetooth/bluetooth_types.h>
|
||||
#include <bluetooth/gap_le_connect.h>
|
||||
#include <util/list.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct GattOperation GattOperation;
|
||||
|
||||
typedef enum {
|
||||
ConnectionFlag_IsSubscribedToConnectionStatusNotifications = 0,
|
||||
ConnectionFlag_IsSubscribedToGattMtuNotifications,
|
||||
ConnectionFlag_IsSubscribedToConnParamNotifications,
|
||||
ConnectionFlag_ShouldPinAddress,
|
||||
//! @note The flag in the Connection struct is only relevant during the pairing process.
|
||||
//! Once bonded, the value gets stored in the bonding list (storage.c / device_t).
|
||||
ConnectionFlag_ShouldAutoAcceptRePairing,
|
||||
//! @note The flag in the Connection struct is only relevant during the pairing process.
|
||||
//! Once bonded, the value gets stored in the bonding list (storage.c / device_t).
|
||||
ConnectionFlag_IsReversedPPoGATTEnabled,
|
||||
ConnectionFlagCount,
|
||||
} ConnectionFlag;
|
||||
|
||||
typedef struct Connection {
|
||||
ListNode node;
|
||||
|
||||
uint16_t conn_idx;
|
||||
|
||||
//! Remote address at the time the connection was established.
|
||||
//! This can be the actual connection address OR the resolved address.
|
||||
//! The former is the case for unbonded connections (including yet-to-be-bonded connections).
|
||||
//! The latter is the case for bonded reconnections: if we are bonded (have an IRK) and the
|
||||
//! underlying stack was able to resolve the address before passing the connection establishment
|
||||
//! event to ble_task.
|
||||
BTDeviceInternal initial_addr;
|
||||
|
||||
//! Updated remote address. In case the address got resolved some time after connecting,
|
||||
//! for example after pairing happened, the resolved address will be stored in this field.
|
||||
//! The initial address will stay stored in initial_addr and the resolved address will be set in
|
||||
//! this field. For bonded reconnections, this field will not be used (remain all zeroes).
|
||||
bool has_updated_addr;
|
||||
BTDeviceInternal updated_addr;
|
||||
|
||||
//! Local address at the time the connection was created.
|
||||
BTDeviceAddress local_addr;
|
||||
|
||||
GattOperation *gatt_op_list;
|
||||
|
||||
bool is_gateway;
|
||||
|
||||
//! @see pebble_pairing_service.c
|
||||
uint32_t flags;
|
||||
BleConnectionParams conn_params;
|
||||
uint8_t last_pairing_result;
|
||||
|
||||
//! @see ppogatt_emulated_server_wa.c
|
||||
PPoGATTWorkAroundState *ppogatt_wa_state;
|
||||
} Connection;
|
||||
|
||||
_Static_assert((sizeof(((Connection *)0)->flags) * 8) >= ConnectionFlagCount,
|
||||
"Bitfield 'flags' full!");
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
//! This is a debug utlility that makes it easy to toggle gpios to debug paths which are very
|
||||
//! sensitive to timing.
|
||||
//! To use it simply:
|
||||
//! 1) Call debug_gpio_init() before you want to track things
|
||||
//! 2) Call debug_gpio_toggle() to flip the gpio state
|
||||
|
||||
//! Initializs DEBUG_GPIOs defined in board config and drives them all low
|
||||
void debug_gpio_init(void);
|
||||
|
||||
//! Toggles the debug_gpio from it's current state
|
||||
void debug_gpio_toggle(int debug_gpio_num);
|
||||
|
||||
//! Drives the state of the specified debug gpio
|
||||
void debug_gpio_set_active(int debug_gpio, bool is_active);
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
void debug_reboot_reason_print(void);
|
||||
21
src/bluetooth-fw/da1468x/controller/main/include/debugger.h
Normal file
21
src/bluetooth-fw/da1468x/controller/main/include/debugger.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if NO_WATCHDOG
|
||||
void debugger_await(void);
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user