Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DIOT Monitoring Module
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Projects
DIOT Monitoring Module
Commits
2bbd72d1
Commit
2bbd72d1
authored
5 years ago
by
Christos Gentsos
Browse files
Options
Downloads
Patches
Plain Diff
Mitig: TMR more variables and some function calls
parent
cc9d8c11
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
common/src/checksums.c
+17
-4
17 additions, 4 deletions
common/src/checksums.c
common/src/float_utils.c
+3
-2
3 additions, 2 deletions
common/src/float_utils.c
common/src/i2c_slave.c
+1
-1
1 addition, 1 deletion
common/src/i2c_slave.c
main_fw/src/i2c_impl.c
+3
-2
3 additions, 2 deletions
main_fw/src/i2c_impl.c
with
24 additions
and
9 deletions
common/src/checksums.c
+
17
−
4
View file @
2bbd72d1
#include
<atmel_start.h>
#include
<COAST.h>
#include
"checksums.h"
int
sysv_checksum
(
uint8_t
*
start_addr
,
uint8_t
*
end_addr
)
int
__xMR_FN_CALL
sysv_checksum
(
uint8_t
*
start_addr
,
uint8_t
*
end_addr
)
{
uint32_t
result
=
0
;
uint16_t
result16
=
0
;
...
...
@@ -13,7 +14,7 @@ int sysv_checksum(uint8_t *start_addr, uint8_t *end_addr)
return
(
result16
&
0xffff
)
+
(
result16
>>
16
);
}
uint8_t
crc8_byte
(
uint8_t
n
)
uint8_t
__xMR_FN_CALL
crc8_byte
(
uint8_t
n
)
{
uint8_t
poly
=
0x07
;
/* x^8 + x^2 + x + 1 */
uint8_t
crc
=
n
;
...
...
@@ -25,11 +26,23 @@ uint8_t crc8_byte(uint8_t n)
return
crc
;
}
uint8_t
crc8_bytearray
(
uint8_t
*
na
,
uint8_t
len
)
static
uint8_t
crc8_byte_notmr
(
uint8_t
n
)
{
uint8_t
poly
=
0x07
;
/* x^8 + x^2 + x + 1 */
uint8_t
crc
=
n
;
for
(
uint8_t
i
=
0
;
i
<
8
;
++
i
)
if
(
crc
&
0x80
)
crc
=
((
crc
<<
1
)
^
poly
);
else
crc
=
(
crc
<<
1
);
return
crc
;
}
uint8_t
__xMR_FN_CALL
crc8_bytearray
(
uint8_t
*
na
,
uint8_t
len
)
{
uint8_t
result
=
0
;
for
(
uint8_t
i
=
0
;
i
<
len
;
++
i
)
{
result
=
crc8_byte
(
result
^
na
[
i
]);
result
=
crc8_byte
_notmr
(
result
^
na
[
i
]);
}
return
result
;
}
This diff is collapsed.
Click to expand it.
common/src/float_utils.c
+
3
−
2
View file @
2bbd72d1
#include
<atmel_start.h>
#include
<math.h>
#include
<COAST.h>
uint16_t
float_to_linear
(
float
val
)
uint16_t
__xMR_FN_CALL
float_to_linear
(
float
val
)
{
// only works with positive numbers for now
int32_t
exp
=
ceilf
(
log2f
(
val
)
-
log2f
(
1023
));
...
...
@@ -20,7 +21,7 @@ uint16_t float_to_linear(float val)
}
float
linear_to_float
(
uint16_t
val
)
float
__xMR_FN_CALL
linear_to_float
(
uint16_t
val
)
{
int16_t
exp
=
((
val
&
0x8000
)
?
0xffe0
:
0
)
|
((
val
>>
11
)
&
0x1f
);
int16_t
man
=
((
val
&
0x0400
)
?
0xf800
:
0
)
|
(
val
&
0x7ff
);
...
...
This diff is collapsed.
Click to expand it.
common/src/i2c_slave.c
+
1
−
1
View file @
2bbd72d1
...
...
@@ -15,7 +15,7 @@
#define send_nack(descr) hri_sercomi2cs_set_CTRLB_ACKACT_bit(descr->device.hw)
#define set_cmd(descr, cmd) hri_sercomi2cs_write_CTRLB_CMD_bf(descr->device.hw, cmd);
static
struct
io_descriptor
*
io
;
static
struct
io_descriptor
*
io
__xMR
;
static
uint16_t
rx_state
__xMR
=
CMD
;
static
uint8_t
std_cmd_addr
;
...
...
This diff is collapsed.
Click to expand it.
main_fw/src/i2c_impl.c
+
3
−
2
View file @
2bbd72d1
#include
<atmel_start.h>
#include
<stdlib.h>
#include
<COAST.h>
#include
<i2c_slave.h>
#include
<flash_utils.h>
#include
<usb_debug.h>
...
...
@@ -13,7 +14,7 @@ const char MFR_DAT[] = "190801";
const
char
MFR_SER
[]
=
"123456789"
;
void
page_chk
();
uint
8
_t
page
;
uint
16
_t
page
__xMR
;
void
accvolt
();
void
acccurr
();
...
...
@@ -128,7 +129,7 @@ void boot_new_fw()
}
void
page_chk
()
void
__xMR
page_chk
()
{
if
(
page
>
2
)
page
=
2
;
...
...
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