mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
add first commands to toggle core connectivity
This commit is contained in:
parent
17cc92eadd
commit
a7684343f2
1 changed files with 40 additions and 2 deletions
|
|
@ -17,21 +17,49 @@ mod implementation {
|
||||||
|
|
||||||
pub struct UsbTest {
|
pub struct UsbTest {
|
||||||
pub(crate) conn: CID,
|
pub(crate) conn: CID,
|
||||||
|
gpio_csr: utralib::CSR<u32>,
|
||||||
|
usb: xous::MemoryRange,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UsbTest {
|
impl UsbTest {
|
||||||
pub fn new(sid: xous::SID) -> UsbTest {
|
pub fn new(sid: xous::SID) -> UsbTest {
|
||||||
|
let gpio_base = xous::syscall::map_memory(
|
||||||
|
xous::MemoryAddress::new(utra::gpio::HW_GPIO_BASE),
|
||||||
|
None,
|
||||||
|
4096,
|
||||||
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
|
)
|
||||||
|
.expect("couldn't map GPIO CSR range");
|
||||||
|
// this particular core does not use CSRs for control - it uses directly memory mapped registers
|
||||||
|
let usb = xous::syscall::map_memory(
|
||||||
|
xous::MemoryAddress::new(utralib::HW_USBDEV_MEM),
|
||||||
|
None,
|
||||||
|
utralib::HW_USBDEV_MEM_LEN,
|
||||||
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
|
)
|
||||||
|
.expect("couldn't map USB device memory range");
|
||||||
|
|
||||||
let mut usbtest = UsbTest {
|
let mut usbtest = UsbTest {
|
||||||
|
gpio_csr: CSR::new(gpio_base.as_mut_ptr() as *mut u32),
|
||||||
conn: xous::connect(sid).unwrap(),
|
conn: xous::connect(sid).unwrap(),
|
||||||
|
usb,
|
||||||
};
|
};
|
||||||
usbtest
|
usbtest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn connect_device_core(&mut self, state: bool) {
|
||||||
|
if state {
|
||||||
|
log::info!("connecting USB device core");
|
||||||
|
self.gpio_csr.wfo(utra::gpio::USBSELECT_USBSELECT, 1);
|
||||||
|
} else {
|
||||||
|
log::info!("connecting USB debug core");
|
||||||
|
self.gpio_csr.wfo(utra::gpio::USBSELECT_USBSELECT, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn suspend(&mut self) {
|
pub fn suspend(&mut self) {
|
||||||
// self.susres_manager.suspend();
|
|
||||||
}
|
}
|
||||||
pub fn resume(&mut self) {
|
pub fn resume(&mut self) {
|
||||||
// self.susres_manager.resume();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,6 +140,13 @@ fn xmain() -> ! {
|
||||||
"test" => {
|
"test" => {
|
||||||
log::info!("got test command with arg {}", args);
|
log::info!("got test command with arg {}", args);
|
||||||
}
|
}
|
||||||
|
"conn" => {
|
||||||
|
match args {
|
||||||
|
"1" => usbtest.connect_device_core(true),
|
||||||
|
"0" => usbtest.connect_device_core(false),
|
||||||
|
_ => log::info!("conn [1,0], got: {}", args),
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
log::info!("unrecognied command {}", cmd);
|
log::info!("unrecognied command {}", cmd);
|
||||||
}
|
}
|
||||||
|
|
@ -122,6 +157,9 @@ fn xmain() -> ! {
|
||||||
"help" => {
|
"help" => {
|
||||||
log::info!("wouldn't that be nice...");
|
log::info!("wouldn't that be nice...");
|
||||||
}
|
}
|
||||||
|
"conn" => {
|
||||||
|
usbtest.connect_device_core(true);
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
log::info!("unrecognized command");
|
log::info!("unrecognized command");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue