// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

use anyhow::Result;
use structopt::StructOpt;

use crate::backend::BackendOpts;
use crate::transport::cw310::CW310;
use crate::transport::Transport;

#[derive(Debug, StructOpt)]
pub struct Cw310Opts {
    #[structopt(
        long,
        help = "Comma-separated list of CW310 UARTs for non-udev environments. List the console uart first."
    )]
    pub cw310_uarts: Option<String>,
}

pub fn create(args: &BackendOpts) -> Result<Box<dyn Transport>> {
    let uarts = args
        .cw310_opts
        .cw310_uarts
        .as_ref()
        .map(|v| v.split(',').collect::<Vec<&str>>())
        .unwrap_or(Vec::new());
    Ok(Box::new(CW310::new(
        args.usb_vid,
        args.usb_vid,
        args.usb_serial.as_deref(),
        &uarts,
    )?))
}

// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

use anyhow::Result;
use structopt::StructOpt;

use crate::backend::BackendOpts;
use crate::transport::cw310::CW310;
use crate::transport::Transport;

#[derive(Debug, StructOpt)]
pub struct Cw310Opts {
    #[structopt(
        long,
        help = "Comma-separated list of CW310 UARTs for non-udev environments. List the console uart first."
    )]
    pub cw310_uarts: Option<String>,
}

pub fn create(args: &BackendOpts) -> Result<Box<dyn Transport>> {
    let uarts = args
        .cw310_opts
        .cw310_uarts
        .as_ref()
        .map(|v| v.split(',').collect::<Vec<&str>>())
        .unwrap_or(Vec::new());
    Ok(Box::new(CW310::new(
        args.usb_vid,
        args.usb_pid,
        args.usb_serial.as_deref(),
        &uarts,
    )?))
}

Fix typo in CW310 backend
[opentitantool] Fix typo in CW310 backend

Signed-off-by: Jorge Prendes <e1833ed3bb567a7d246d72b65c4144d1037bd875@gmail.com>
