1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! Driver for the Sensortek STK8BA58 3-axis MEMS Accelerometer
//!
//! Implements the [`Accelerometer` trait](https://docs.rs/accelerometer/latest/accelerometer/trait.Accelerometer.html)
//! from the `accelerometer` crate.
//!
//! # How to use
//! ## Reading the acceleration:
//! ```no_run
//! use stk8ba58::Stk8ba58;
//! use accelerometer::{vector::I16x3, Accelerometer};
//!
//! // i2c is an I2C bus you have previously initialized with your HAL
//! let mut accelerometer = Stk8ba58::new(i2c);
//!
//! let acceleration = accelerometer.accel_norm().unwrap();
//! let x_component = acceleration.x;
//! let y_component = acceleration.y;
//! let z_component = acceleration.z;
//! ```
//!
//! ## Setting register flags:
//! ```no_run
//! use stk8ba58::{
//! registers::{Write, INTEN1},
//! Stk8ba58,
//! };
//!
//! // i2c is an I2C bus you have previously initialized with your HAL
//! let mut accelerometer = Stk8ba58::new(i2c);
//!
//! // Enable slope interrupt for the X and Y axis.
//! let flags = INTEN1::SLP_EN_X | INTEN1::SLP_EN_Y;
//! accelerometer.set_flags(flags).unwrap();
//! ```
//!
//! ## Reading set values:
//! ```no_run
//! use stk8ba58::{
//! registers::{Read, SleepDuration},
//! Stk8ba58,
//! };
//!
//! // i2c is an I2C bus you have previously initialized with your HAL
//! let mut accelerometer = Stk8ba58::new(i2c);
//!
//! let sleep_duration = accelerometer.sleep_duration().unwrap();
//! if sleep_duration == SleepDuration::Ms10 {
//! // Accelerometer is configured to have a 10ms sleep phase.
//! }
//! ```
use Debug;
use Error;
use I2c;
use ;
/// Software representation of the STK8BA58.
///
/// Create it with [`Stk8ba58::new()`] or check out the [examples](https://gitlab.com/slusheea/stk8ba58/-/tree/main/examples)