Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OpenSK
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
koenigl2
OpenSK
Commits
f1932980
Commit
f1932980
authored
4 years ago
by
tamaf96
Browse files
Options
Downloads
Patches
Plain Diff
take care of return values (TockResults)
parent
dd750ddc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main.rs
+1
-1
1 addition, 1 deletion
src/main.rs
src/usb_ctap_hid.rs
+30
-12
30 additions, 12 deletions
src/usb_ctap_hid.rs
with
31 additions
and
13 deletions
src/main.rs
+
1
−
1
View file @
f1932980
...
@@ -66,7 +66,7 @@ async fn main() -> TockResult<()> {
...
@@ -66,7 +66,7 @@ async fn main() -> TockResult<()> {
let
timer
=
timer
.init
()
?
;
let
timer
=
timer
.init
()
?
;
// Setup USB driver.
// Setup USB driver.
if
!
usb_ctap_hid
::
setup
()
{
if
!
usb_ctap_hid
::
setup
()
?
{
panic!
(
"Cannot setup USB driver"
);
panic!
(
"Cannot setup USB driver"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/usb_ctap_hid.rs
+
30
−
12
View file @
f1932980
...
@@ -17,7 +17,7 @@ use core::cell::Cell;
...
@@ -17,7 +17,7 @@ use core::cell::Cell;
use
core
::
fmt
::
Write
;
use
core
::
fmt
::
Write
;
#[cfg(feature
=
"debug_ctap"
)]
#[cfg(feature
=
"debug_ctap"
)]
use
libtock
::
console
::
Console
;
use
libtock
::
console
::
Console
;
use
libtock
::
result
::{
EALREADY
,
EBUSY
,
SUCCESS
};
use
libtock
::
result
::{
EALREADY
,
EBUSY
,
SUCCESS
,
TockResult
};
use
libtock
::
syscalls
;
use
libtock
::
syscalls
;
use
libtock
::
timer
::{
Duration
};
use
libtock
::
timer
::{
Duration
};
...
@@ -48,18 +48,18 @@ mod allow_nr {
...
@@ -48,18 +48,18 @@ mod allow_nr {
pub
const
TRANSMIT_OR_RECEIVE
:
usize
=
3
;
pub
const
TRANSMIT_OR_RECEIVE
:
usize
=
3
;
}
}
pub
fn
setup
()
->
bool
{
pub
fn
setup
()
->
TockResult
<
bool
>
{
let
result
=
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
CHECK
,
0
,
0
)
};
let
result
=
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
CHECK
,
0
,
0
)
?
};
if
result
!=
0
{
if
result
!=
0
{
return
false
;
return
Ok
(
false
)
;
}
}
let
result
=
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
CONNECT
,
0
,
0
)
};
let
result
=
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
CONNECT
,
0
,
0
)
?
};
if
result
!=
0
{
if
result
!=
0
{
return
false
;
return
Ok
(
false
)
;
}
}
true
Ok
(
true
)
}
}
#[allow(dead_code)]
#[allow(dead_code)]
...
@@ -76,7 +76,11 @@ pub fn recv(buf: &mut [u8; 64]) -> bool {
...
@@ -76,7 +76,11 @@ pub fn recv(buf: &mut [u8; 64]) -> bool {
return
false
;
return
false
;
}
}
let
result_code
=
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
RECEIVE
,
0
,
0
)
};
let
result_code
=
match
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
RECEIVE
,
0
,
0
)
}
{
Ok
(
x
)
=>
x
,
Err
(
err
)
=>
panic!
(
"Unexpected error error while executing command"
),
};
if
result_code
!=
0
{
if
result_code
!=
0
{
return
false
;
return
false
;
}
}
...
@@ -99,7 +103,11 @@ pub fn send(buf: &mut [u8; 64]) -> bool {
...
@@ -99,7 +103,11 @@ pub fn send(buf: &mut [u8; 64]) -> bool {
return
false
;
return
false
;
}
}
let
result_code
=
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
TRANSMIT
,
0
,
0
)
};
let
result_code
=
match
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
TRANSMIT
,
0
,
0
)
}
{
Ok
(
x
)
=>
x
,
Err
(
err
)
=>
panic!
(
"Unexpected error error while executing command"
),
};
if
result_code
!=
0
{
if
result_code
!=
0
{
return
false
;
return
false
;
}
}
...
@@ -149,7 +157,10 @@ pub fn send_or_recv(buf: &mut [u8; 64]) -> SendOrRecvStatus {
...
@@ -149,7 +157,10 @@ pub fn send_or_recv(buf: &mut [u8; 64]) -> SendOrRecvStatus {
}
}
let
result_code
=
let
result_code
=
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
TRANSMIT_OR_RECEIVE
,
0
,
0
)
};
match
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
TRANSMIT_OR_RECEIVE
,
0
,
0
)
}
{
Ok
(
x
)
=>
x
,
Err
(
err
)
=>
panic!
(
"Unexpected error error while executing command"
),
};
if
result_code
!=
0
{
if
result_code
!=
0
{
return
SendOrRecvStatus
::
Error
;
return
SendOrRecvStatus
::
Error
;
}
}
...
@@ -256,7 +267,11 @@ fn recv_with_timeout_detail(
...
@@ -256,7 +267,11 @@ fn recv_with_timeout_detail(
};
};
// Trigger USB reception.
// Trigger USB reception.
let
result_code
=
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
RECEIVE
,
0
,
0
)
};
let
result_code
=
match
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
RECEIVE
,
0
,
0
)
}
{
Ok
(
x
)
=>
x
,
Err
(
err
)
=>
panic!
(
"Unexpected error error while executing command"
),
};
if
result_code
!=
0
{
if
result_code
!=
0
{
return
Some
(
SendOrRecvStatus
::
Error
);
return
Some
(
SendOrRecvStatus
::
Error
);
}
}
...
@@ -357,7 +372,10 @@ fn send_or_recv_with_timeout_detail(
...
@@ -357,7 +372,10 @@ fn send_or_recv_with_timeout_detail(
// Trigger USB transmission.
// Trigger USB transmission.
let
result_code
=
let
result_code
=
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
TRANSMIT_OR_RECEIVE
,
0
,
0
)
};
match
unsafe
{
syscalls
::
command
(
DRIVER_NUMBER
,
command_nr
::
TRANSMIT_OR_RECEIVE
,
0
,
0
)
}
{
Ok
(
x
)
=>
x
,
Err
(
err
)
=>
panic!
(
"Unexpected error error while executing command"
),
};
if
result_code
!=
0
{
if
result_code
!=
0
{
return
Some
(
SendOrRecvStatus
::
Error
);
return
Some
(
SendOrRecvStatus
::
Error
);
}
}
...
...
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