Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sensirion_sht4x
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
andrea.tambani@studenti.unimi.it
sensirion_sht4x
Commits
11b02b57
Commit
11b02b57
authored
3 months ago
by
andrea.tambani@studenti.unimi.it
Browse files
Options
Downloads
Patches
Plain Diff
destroy method added
parent
89fd43db
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib.rs
+14
-2
14 additions, 2 deletions
src/lib.rs
src/sht4x_reg.rs
+2
-6
2 additions, 6 deletions
src/sht4x_reg.rs
with
16 additions
and
8 deletions
src/lib.rs
+
14
−
2
View file @
11b02b57
...
...
@@ -52,10 +52,15 @@ pub struct Sht4x<B, T> {
tim
:
T
,
}
pub
struct
Sht4xI2C
<
P
>
{
i2c
:
P
,
address
:
SevenBitAddress
,
}
///
/// The SHT4X driver struct implementation.
///
impl
<
P
,
T
>
Sht4x
<
sht4x_reg
::
Sht4xI2C
<
P
>
,
T
>
impl
<
P
,
T
>
Sht4x
<
Sht4xI2C
<
P
>
,
T
>
where
P
:
I2c
,
T
:
DelayNs
,
...
...
@@ -77,7 +82,7 @@ where
/// * Error: The failure of a bus operation returns Error::Bus(B).
///
pub
fn
new_i2c
(
i2c
:
P
,
address
:
I2CAddress
,
tim
:
T
)
->
Result
<
Self
,
Error
<
P
::
Error
>>
{
let
bus
=
sht4x_reg
::
Sht4xI2C
::
new
(
i2c
,
address
as
SevenBitAddress
);
let
bus
=
Sht4xI2C
::
new
(
i2c
,
address
as
SevenBitAddress
);
let
mut
instance
=
Self
{
bus
,
tim
};
instance
.tim
.delay_ms
(
1
);
instance
.soft_reset
()
?
;
...
...
@@ -110,6 +115,13 @@ pub enum I2CAddress {
}
impl
<
B
:
BusOperation
,
T
:
DelayNs
>
Sht4x
<
B
,
T
>
{
///
/// This method destroys the driver and returns the bus and timer instances.
///
pub
fn
destroy
(
self
)
->
(
B
,
T
)
{
(
self
.bus
,
self
.tim
)
}
///
/// This method returns the sensor serial number.
///
...
...
This diff is collapsed.
Click to expand it.
src/sht4x_reg.rs
+
2
−
6
View file @
11b02b57
...
...
@@ -6,18 +6,14 @@ use embedded_hal::{
use
generic_bus
::
BusOperation
;
use
crate
::
Error
;
pub
struct
Sht4xI2C
<
P
>
{
i2c
:
P
,
address
:
SevenBitAddress
,
}
impl
<
P
:
I2c
>
Sht4xI2C
<
P
>
{
impl
<
P
:
I2c
>
super
::
Sht4xI2C
<
P
>
{
pub
(
super
)
fn
new
(
i2c
:
P
,
address
:
SevenBitAddress
)
->
Self
{
Self
{
i2c
,
address
}
}
}
impl
<
P
:
I2c
>
BusOperation
for
Sht4xI2C
<
P
>
{
impl
<
P
:
I2c
>
BusOperation
for
super
::
Sht4xI2C
<
P
>
{
type
Error
=
P
::
Error
;
#[inline]
...
...
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