Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolò Caruso
Skyward Boardcore
Commits
9fda62c0
"git@git.skywarder.eu:nicolo.caruso/skyward-boardcore.git" did not exist on "a79ad9dde2fafcee2cef0975291d18e5912601ac"
Commit
9fda62c0
authored
2 years ago
by
Davide Mor
Browse files
Options
Downloads
Patches
Plain Diff
[sx1278] Improved sx1278 benchmark
parent
6615c6c6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tests/drivers/sx1278/test-sx1278-bench.cpp
+35
-14
35 additions, 14 deletions
src/tests/drivers/sx1278/test-sx1278-bench.cpp
with
35 additions
and
14 deletions
src/tests/drivers/sx1278/test-sx1278-bench.cpp
+
35
−
14
View file @
9fda62c0
...
@@ -45,6 +45,20 @@ const char *stringFromErr(SX1278::Error err)
...
@@ -45,6 +45,20 @@ const char *stringFromErr(SX1278::Error err)
}
}
}
}
// Simple xorshift RNG
uint32_t
xorshift32
()
{
// https://xkcd.com/221/
static
uint32_t
STATE
=
0x08104444
;
uint32_t
x
=
STATE
;
x
^=
x
<<
13
;
x
^=
x
>>
17
;
x
^=
x
<<
5
;
return
STATE
=
x
;
}
#if defined _BOARD_STM32F429ZI_SKYWARD_GS
#if defined _BOARD_STM32F429ZI_SKYWARD_GS
#include
"interfaces-impl/hwmapping.h"
#include
"interfaces-impl/hwmapping.h"
...
@@ -118,16 +132,13 @@ struct Stats
...
@@ -118,16 +132,13 @@ struct Stats
SX1278
*
sx1278
=
nullptr
;
SX1278
*
sx1278
=
nullptr
;
// Payload size in 32bit blocks
constexpr
size_t
PAYLOAD_SIZE
=
14
;
struct
Msg
struct
Msg
{
{
int
idx
;
uint32_t
idx
;
int
dummy_1
;
uint32_t
payload
[
PAYLOAD_SIZE
];
int
dummy_2
;
int
dummy_3
;
const
static
int
DUMMY_1
=
0xdeadbeef
;
const
static
int
DUMMY_2
=
0xbeefdead
;
const
static
int
DUMMY_3
=
0x1234abcd
;
};
};
void
recvLoop
()
void
recvLoop
()
...
@@ -139,12 +150,15 @@ void recvLoop()
...
@@ -139,12 +150,15 @@ void recvLoop()
int
len
=
sx1278
->
receive
((
uint8_t
*
)
&
msg
,
sizeof
(
msg
));
int
len
=
sx1278
->
receive
((
uint8_t
*
)
&
msg
,
sizeof
(
msg
));
uint32_t
acc
=
0
;
for
(
size_t
i
=
0
;
i
<
PAYLOAD_SIZE
;
i
++
)
acc
^=
msg
.
payload
[
i
];
if
(
len
!=
sizeof
(
msg
))
if
(
len
!=
sizeof
(
msg
))
{
{
stats
.
recv_errors
++
;
stats
.
recv_errors
++
;
}
}
else
if
(
msg
.
dummy_1
!=
Msg
::
DUMMY_1
||
msg
.
dummy_2
!=
Msg
::
DUMMY_2
||
else
if
(
acc
!=
0
)
msg
.
dummy_3
!=
Msg
::
DUMMY_3
)
{
{
stats
.
recv_errors
++
;
stats
.
recv_errors
++
;
stats
.
corrupted_packets
++
;
stats
.
corrupted_packets
++
;
...
@@ -165,9 +179,16 @@ void sendLoop()
...
@@ -165,9 +179,16 @@ void sendLoop()
Msg
msg
;
Msg
msg
;
msg
.
idx
=
next_idx
;
msg
.
idx
=
next_idx
;
msg
.
dummy_1
=
Msg
::
DUMMY_1
;
msg
.
dummy_2
=
Msg
::
DUMMY_2
;
// Setup the buffer so that the xor of the full thing is 0
msg
.
dummy_3
=
Msg
::
DUMMY_3
;
uint32_t
acc
=
0
;
for
(
size_t
i
=
0
;
i
<
PAYLOAD_SIZE
-
1
;
i
++
)
{
// Fill only the lower 8bit to simulate a lot of zeroes
msg
.
payload
[
i
]
=
xorshift32
()
&
0xff
;
acc
^=
msg
.
payload
[
i
];
}
msg
.
payload
[
PAYLOAD_SIZE
-
1
]
=
acc
;
sx1278
->
send
((
uint8_t
*
)
&
msg
,
sizeof
(
msg
));
sx1278
->
send
((
uint8_t
*
)
&
msg
,
sizeof
(
msg
));
stats
.
send_count
=
next_idx
;
stats
.
send_count
=
next_idx
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment