Skip to content

Commit

Permalink
boards/opentitan: Create the USB CDC Component
Browse files Browse the repository at this point in the history
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
  • Loading branch information
alistair23 committed Sep 3, 2020
1 parent 79b6c55 commit fa5161e
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions boards/opentitan/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use kernel::component::Component;
use kernel::hil;
use kernel::hil::i2c::I2CMaster;
use kernel::hil::time::Alarm;
use kernel::hil::usb::Client;
use kernel::Chip;
use kernel::Platform;
use kernel::{create_capability, debug, static_init};
Expand Down Expand Up @@ -256,8 +257,6 @@ pub unsafe fn reset_handler() {
[u8; 32]
));

let usb = usb::UsbComponent::new(board_kernel).finalize(());

let i2c_master = static_init!(
capsules::i2c_master::I2CMasterDriver<lowrisc::i2c::I2c<'static>>,
capsules::i2c_master::I2CMasterDriver::new(
Expand All @@ -269,6 +268,33 @@ pub unsafe fn reset_handler() {

earlgrey::i2c::I2C.set_master_client(i2c_master);

let usb = usb::UsbComponent::new(board_kernel).finalize(());

// Create the strings we include in the USB descriptor.
let strings = static_init!(
[&str; 3],
[
"LowRISC.", // Manufacturer
"OpenTitan - TockOS", // Product
"18d1:503a", // Serial number
]
);

let cdc = components::cdc::CdcAcmComponent::new(
&earlgrey::usbdev::USB,
capsules::usb::cdc::MAX_CTRL_PACKET_SIZE_NRF52840,
0x18d1, // 0x18d1 Google Inc.
0x503a, // lowRISC generic FS USB
strings,
)
.finalize(components::usb_cdc_acm_component_helper!(
lowrisc::usbdev::Usb
));

// Configure the USB stack to enable a serial port over CDC-ACM.
cdc.enable();
cdc.attach();

debug!("OpenTitan initialisation complete. Entering main loop");

/// These symbols are defined in the linker script.
Expand Down

0 comments on commit fa5161e

Please sign in to comment.