File tree 2 files changed +14
-7
lines changed
2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ use crate::gpio::GpioDriverFactory;
5
5
use crate :: leds:: LedsDriverFactory ;
6
6
use crate :: result:: OtherError ;
7
7
use crate :: result:: TockError ;
8
- use crate :: result:: TockResult ;
9
8
use crate :: rng:: RngDriver ;
10
9
use crate :: sensors:: ninedof:: NinedofDriver ;
11
10
use crate :: sensors:: AmbientLightSensor ;
@@ -37,12 +36,12 @@ pub struct Drivers {
37
36
}
38
37
39
38
/// Retrieve [Drivers] struct. Returns struct only once.
40
- pub fn retrieve_drivers ( ) -> TockResult < Drivers > {
39
+ pub fn retrieve_drivers ( ) -> Result < Drivers , DriversAlreadyTakenError > {
41
40
static mut DRIVER_TAKEN : bool = false ;
42
41
43
42
unsafe {
44
43
if DRIVER_TAKEN {
45
- Err ( TockError :: Other ( OtherError :: DriverAlreadyTaken ) )
44
+ Err ( DriversAlreadyTakenError )
46
45
} else {
47
46
DRIVER_TAKEN = true ;
48
47
Ok ( retrieve_drivers_unsafe ( ) )
@@ -79,3 +78,11 @@ const DRIVERS: Drivers = Drivers {
79
78
humidity_sensor : HumiditySensor ,
80
79
ninedof : NinedofDriver ,
81
80
} ;
81
+
82
+ pub struct DriversAlreadyTakenError ;
83
+
84
+ impl From < DriversAlreadyTakenError > for TockError {
85
+ fn from ( _: DriversAlreadyTakenError ) -> Self {
86
+ TockError :: Other ( OtherError :: DriversAlreadyTaken )
87
+ }
88
+ }
Original file line number Diff line number Diff line change @@ -50,8 +50,8 @@ pub enum OtherError {
50
50
GpioDriverInvalidState ,
51
51
TimerDriverDurationOutOfRange ,
52
52
TimerDriverErroneousClockFrequency ,
53
- DriverAlreadyTaken ,
54
- OutOfRangeError ,
53
+ DriversAlreadyTaken ,
54
+ OutOfRange ,
55
55
}
56
56
57
57
impl From < OtherError > for TockError {
@@ -63,7 +63,7 @@ impl From<OtherError> for TockError {
63
63
pub struct OutOfRangeError ;
64
64
65
65
impl From < OutOfRangeError > for TockError {
66
- fn from ( _other : OutOfRangeError ) -> Self {
67
- TockError :: Other ( OtherError :: OutOfRangeError )
66
+ fn from ( _ : OutOfRangeError ) -> Self {
67
+ TockError :: Other ( OtherError :: OutOfRange )
68
68
}
69
69
}
You can’t perform that action at this time.
0 commit comments