Skip to content

Commit 4158747

Browse files
committed
Add comments and remove whitespaces
1 parent 4617689 commit 4158747

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

application/src/control.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ impl ControlClass {
118118
},
119119
}
120120
}
121+
/// This function is called after processing USB control OUT requests to handle any necessary
122+
/// work regarding the commands executed in the control_out method.
123+
///
124+
/// The post_poll function performs actions based on the data that was set during the
125+
/// control_out phase, including refreshing measurements from the power meter, updating
126+
/// the state of control pins, and executing power or storage actions. This separation allows
127+
/// the class to batch actions that need to be taken after all USB transactions have been completed,
128+
/// ensuring that changes are applied in a controlled manner.
129+
///
121130
pub fn post_poll<C: CTLPinsTrait, S: StorageSwitchTrait>(
122131
&mut self,
123132
config: &mut ConfigArea,
@@ -239,6 +248,18 @@ impl<B: UsbBus> UsbClass<B> for ControlClass {
239248
Ok(())
240249
}
241250

251+
/// Handles control transfer IN requests from the host.
252+
///
253+
/// This function processes various vendor-specific requests, such as:
254+
/// - Retrieving configuration settings for the device (name, tags, USB console, power settings).
255+
/// - Providing information about the current power state, voltage, and current readings.
256+
/// - Responding with the device's version information.
257+
///
258+
/// The function checks the request type and recipient, and parses the
259+
/// request value to determine which data to send back to the host.
260+
/// Appropriate responses are constructed based on the parsed request.
261+
///
262+
/// The responses will be sent back to the host through the ControlIn transfer.
242263
fn control_in(&mut self, xfer: ControlIn<B>) {
243264
let req = xfer.request();
244265

@@ -318,7 +339,22 @@ impl<B: UsbBus> UsbClass<B> for ControlClass {
318339
}
319340
}
320341
}
321-
342+
/// Handles control transfer OUT requests from the host.
343+
///
344+
/// This function processes various vendor-specific requests, such as:
345+
/// - Refreshing the data from the power meter.
346+
/// - Setting the power state (on, off, force on/off, or rescue).
347+
/// - Managing storage actions (off, connect to host, or DUT).
348+
/// - Configuring device settings (name, tags, USB console, power settings).
349+
/// - Setting the state of control pins (Reset, A, B, C, D).
350+
///
351+
/// The function checks the request type and recipient, and parses the
352+
/// request value to determine the action to be taken. Appropriate
353+
/// data fields within the control class are updated based on the
354+
/// request.
355+
///
356+
/// Any actions are taken later by the post_poll function once usb polling
357+
/// of all devices has finished.
322358
fn control_out(&mut self, xfer: ControlOut<B>) {
323359
let req = xfer.request();
324360

application/src/dfu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use stm32f4xx_hal::otg_fs::UsbBusType;
44
use usbd_dfu_rt::{DfuRuntimeClass, DfuRuntimeOps};
55
use usb_device::class_prelude::*;
66

7-
pub struct DFUBootloader;
7+
pub struct DFUBootloader;
88

99
pub type DFUBootloaderRuntime = DfuRuntimeClass<DFUBootloader>;
1010

application/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ mod app {
178178
storage.power_off();
179179

180180

181-
// setup a timer for the periodic 100ms task
181+
// setup a timer for the periodic 10ms task
182182
let mut timer = dp.TIM2.counter_ms(&clocks);
183183
timer.start(10.millis()).unwrap(); //100Hz
184184
timer.listen(timer::Event::Update);

0 commit comments

Comments
 (0)