mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-09-27 14:00:04 +00:00
886487dee6
- add intermediate-step solutions - add more hints - refactor exercise & text to have the same amount of work on all OSes - add `usb` parser solutions - make `dk-run` less silent - rename rtic binaries (shorter names) - link to the main svd2rust API docs
30 lines
1,013 B
Rust
30 lines
1,013 B
Rust
use anyhow::anyhow;
|
|
|
|
fn main() -> Result<(), anyhow::Error> {
|
|
for dev in rusb::devices()?.iter() {
|
|
let dev_desc = dev.device_descriptor()?;
|
|
if dev_desc.vendor_id() == consts::VID && dev_desc.product_id() == consts::PID {
|
|
println!("{:#?}", dev_desc);
|
|
println!("address: {}", dev.address());
|
|
for i in 0..dev_desc.num_configurations() {
|
|
let conf_desc = dev.config_descriptor(i)?;
|
|
println!("config{}: {:#?}", i, conf_desc);
|
|
|
|
for iface in conf_desc.interfaces() {
|
|
println!(
|
|
"iface{}: {:#?}",
|
|
iface.number(),
|
|
iface.descriptors().collect::<Vec<_>>()
|
|
);
|
|
}
|
|
}
|
|
|
|
// TODO open the device; this will force the OS to configure it
|
|
// let mut handle = dev.open()?;
|
|
|
|
return Ok(());
|
|
}
|
|
}
|
|
|
|
Err(anyhow!("nRF52840 USB device not found"))
|
|
}
|