Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
m
rust-card10
Commits
b4258747
Commit
b4258747
authored
Aug 24, 2019
by
tibut
Browse files
bhi test
parent
bafea443
Pipeline
#3413
failed with stage
in 8 minutes and 50 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bhi160-loop/Cargo.toml
0 → 100644
View file @
b4258747
[package]
name
=
"bhi160-loop"
version
=
"0.1.0"
authors
=
[
"tibut <marcel.wallschlaeger@tu-berlin.de>"
]
edition
=
"2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
card10-l0dable
=
{
path
=
"../l0dable"
}
\ No newline at end of file
bhi160-loop/src/main.rs
0 → 100644
View file @
b4258747
#![no_std]
#![no_main]
use
core
::
fmt
::{
self
,
Write
};
use
card10_l0dable
::
*
;
main!
(
main
);
fn
main
()
{
let
result
=
run
();
if
let
Err
(
error
)
=
result
{
writeln!
(
UART
,
"error: {}
\r
"
,
error
);
}
}
fn
run
()
->
Result
<
(),
Error
>
{
let
bhi_acc
=
BHI160
::
<
Accelerometer
>
::
start
()
?
;
loop
{
for
d
in
&
bhi_acc
.read
()
?
{
writeln!
(
UART
,
"BHI {:?}
\r
"
,
d
)
.unwrap
();
}
}
}
// -----------------------------------------------------------------------------
// Error
// -----------------------------------------------------------------------------
#[derive(Debug)]
pub
enum
Error
{
UartWriteFailed
(
fmt
::
Error
),
SensorInteractionFailed
(
BHI160Error
),
}
impl
From
<
fmt
::
Error
>
for
Error
{
fn
from
(
error
:
fmt
::
Error
)
->
Self
{
Error
::
UartWriteFailed
(
error
)
}
}
impl
From
<
BHI160Error
>
for
Error
{
fn
from
(
error
:
BHI160Error
)
->
Self
{
Error
::
SensorInteractionFailed
(
error
)
}
}
impl
fmt
::
Display
for
Error
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
match
self
{
Error
::
UartWriteFailed
(
error
)
=>
error
.fmt
(
f
),
Error
::
SensorInteractionFailed
(
error
)
=>
error
.fmt
(
f
),
}
}
}
Write
Preview
Supports
Markdown
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