Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lwc
/
compare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9408cff6
authored
Nov 20, 2019
by
Enrico Pozzobon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
corrected esp32 interrupts
parent
33472d31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
templates/esp32/src/main.ino
+9
-8
No files found.
templates/esp32/src/main.ino
View file @
9408cff6
...
...
@@ -61,11 +61,16 @@ void setup() {
memset
(
ad
,
0
,
MAX_BYTES
);
memset
(
m
,
0
,
MAX_BYTES
);
memset
(
c
,
0
,
MAX_BYTES
);
mlen
=
8
;
adlen
=
0
;
crypto_aead_encrypt
(
c
,
&
clen
,
m
,
mlen
,
ad
,
adlen
,
nsec
,
npub
,
k
);
crypto_aead_decrypt
(
m
,
&
mlen
,
nsec
,
c
,
clen
,
ad
,
adlen
,
npub
,
k
);
SerialOut
.
print
(
"Hello, World!"
);
}
void
loop
()
{
int
res
;
portMUX_TYPE
mux
=
portMUX_INITIALIZER_UNLOCKED
;
uint16_t
len
=
uartp_recv
(
cmdbuf
,
CMDBUF_LEN
-
1
);
uint8_t
action
=
cmdbuf
[
0
];
if
(
len
==
0
||
len
>
CMDBUF_LEN
-
1
)
...
...
@@ -82,22 +87,18 @@ void loop() {
case
'p'
:
my_assert
(
l
==
CRYPTO_NPUBBYTES
);
memcpy
(
npub
,
var
,
l
);
break
;
case
's'
:
my_assert
(
l
==
CRYPTO_NSECBYTES
);
memcpy
(
nsec
,
var
,
l
);
break
;
case
'e'
:
noInterrupts
();
asm
(
"nop"
);
portENTER_CRITICAL
(
&
mux
);
digitalWrite
(
CRYPTO_BUSY
,
LOW
);
res
=
crypto_aead_encrypt
(
c
,
&
clen
,
m
,
mlen
,
ad
,
adlen
,
nsec
,
npub
,
k
);
digitalWrite
(
CRYPTO_BUSY
,
HIGH
);
asm
(
"nop"
);
interrupts
();
portEXIT_CRITICAL
(
&
mux
);
break
;
case
'd'
:
noInterrupts
();
asm
(
"nop"
);
portENTER_CRITICAL
(
&
mux
);
digitalWrite
(
CRYPTO_BUSY
,
LOW
);
res
=
crypto_aead_decrypt
(
m
,
&
mlen
,
nsec
,
c
,
clen
,
ad
,
adlen
,
npub
,
k
);
digitalWrite
(
CRYPTO_BUSY
,
HIGH
);
asm
(
"nop"
);
interrupts
();
portEXIT_CRITICAL
(
&
mux
);
break
;
case
'M'
:
var
=
m
;
rl
=
mlen
;
break
;
case
'C'
:
var
=
c
;
rl
=
clen
;
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment