Skip to content

Commit b688be8

Browse files
committed
1 parent 33965bb commit b688be8

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/lib.rs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ where
104104
/// The initial state of the motors will be set to [stopped](DriveCommand::Stop).
105105
/// The initial state of standby will be *disabled*.
106106
///
107-
/// Usage example:
107+
/// # Errors
108+
/// If any of the underlying pin interactions fail these errors will be propagated up.
109+
/// The errors are specific to your HAL.
110+
///
111+
/// # Usage example
108112
/// ```
109113
/// # use embedded_hal_mock::eh1::digital::Mock as PinMock;
110114
/// # use embedded_hal_mock::eh1::pwm::Mock as PwmMock;
@@ -189,18 +193,30 @@ where
189193
///
190194
/// Note that this does not change any commands on the motors, i.e. the PWM signal will continue
191195
/// and once [`Tb6612fng::disable_standby`] is called the motor will pick up where it left off (unless the command was changed in-between).
196+
///
197+
/// # Errors
198+
/// If the underlying pin interaction fails this error will be propagated up.
199+
/// The error is specific to your HAL.
192200
pub fn enable_standby(&mut self) -> Result<(), STBY::Error> {
193201
self.standby.set_low()
194202
}
195203

196204
/// Disable standby. Note that the last active commands on the motors will resume.
205+
///
206+
/// # Errors
207+
/// If the underlying pin interaction fails this error will be propagated up.
208+
/// The error is specific to your HAL.
197209
pub fn disable_standby(&mut self) -> Result<(), STBY::Error> {
198210
self.standby.set_high()
199211
}
200212

201213
/// Returns whether the standby mode is enabled.
202214
///
203215
/// *NOTE* this does *not* read the electrical state of the pin, see [`StatefulOutputPin`]
216+
///
217+
/// # Errors
218+
/// If the underlying pin interaction fails this error will be propagated up.
219+
/// The error is specific to your HAL.
204220
pub fn current_standby(&mut self) -> Result<bool, STBY::Error>
205221
where
206222
STBY: StatefulOutputPin,
@@ -210,6 +226,7 @@ where
210226
}
211227

212228
/// Represents a single motor (either motor A or motor B) hooked up to a TB6612FNG controller.
229+
///
213230
/// This is unaware of the standby pin. If you plan on using both motors and the standby feature then use the [`Tb6612fng`] struct instead.
214231
/// See the crate-level comment for further details on when to use what.
215232
#[derive(Debug)]
@@ -231,7 +248,11 @@ where
231248
/// This also automatically enables the PWM pin.
232249
/// The initial state of the motor will be set to [stopped](DriveCommand::Stop).
233250
///
234-
/// Usage example:
251+
/// # Errors
252+
/// If any of the underlying pin interactions fail these errors will be propagated up.
253+
/// The errors are specific to your HAL.
254+
///
255+
/// # Usage example
235256
/// ```
236257
/// # use embedded_hal_mock::eh1::digital::Mock as PinMock;
237258
/// # use embedded_hal_mock::eh1::pwm::Mock as PwmMock;
@@ -275,6 +296,13 @@ where
275296
}
276297

277298
/// Drive with the defined speed (or brake or stop the motor).
299+
///
300+
/// # Errors
301+
/// If the underlying pin interaction fails this error will be propagated up.
302+
/// The error is specific to your HAL.
303+
///
304+
/// The specified speed must be between 0 and 100 (inclusive), otherwise you will get a
305+
/// [`MotorError::InvalidSpeed`] error.
278306
#[allow(clippy::type_complexity)]
279307
pub fn drive(
280308
&mut self,
@@ -330,7 +358,7 @@ where
330358
/// Return the current speed of the motor (in percentage). Note that driving forward returns a positive number
331359
/// while driving backward returns a negative number and both [`DriveCommand::Brake`] and [`DriveCommand::Stop`] return 0.
332360
///
333-
/// If you need to know in more details what the current status is consider calling [`Motor::current_drive_command`] instead.
361+
/// If you need to know in more details what the current status is, consider calling [`Motor::current_drive_command`] instead.
334362
pub fn current_speed(&self) -> i8 {
335363
match self.current_drive_command() {
336364
DriveCommand::Forward(s) => *s as i8,

0 commit comments

Comments
 (0)