mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add dabao support to usb-bao1x
the minimal set of envisioned services for the dabao would include a USB handler. Seems like too useful a thing to not have it enabled.
This commit is contained in:
parent
4069b623c4
commit
140f1ae538
3 changed files with 19 additions and 9 deletions
|
|
@ -58,6 +58,7 @@ board-baosec = [
|
||||||
"bao1x-hal",
|
"bao1x-hal",
|
||||||
"bao1x-hal-service",
|
"bao1x-hal-service",
|
||||||
]
|
]
|
||||||
|
board-dabao = ["utralib/bao1x", "utralib/std", "bao1x-hal", "bao1x-hal-service"]
|
||||||
hosted-baosec = ["utralib/hosted", "utralib/std", "bao1x-emu"]
|
hosted-baosec = ["utralib/hosted", "utralib/std", "bao1x-emu"]
|
||||||
# none of these other modes are actually supported, but are listed here
|
# none of these other modes are actually supported, but are listed here
|
||||||
# to allow direct re-use of API code
|
# to allow direct re-use of API code
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,9 @@ impl<'a> Bao1xUsb<'a> {
|
||||||
self.irq_csr.wfo(utra::irqarray1::EV_SOFT_TRIGGER, SW_IRQ_MASK);
|
self.irq_csr.wfo(utra::irqarray1::EV_SOFT_TRIGGER, SW_IRQ_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process an unplug event
|
/// Process an unplug event - only valid on baosec, because dabao doesn't have a battery and unplugging
|
||||||
|
/// it would power it down.
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
pub fn unplug(&mut self) {
|
pub fn unplug(&mut self) {
|
||||||
// disable all interrupts so we can safely go through initialization routines
|
// disable all interrupts so we can safely go through initialization routines
|
||||||
self.irq_csr.wo(utra::irqarray1::EV_ENABLE, 0);
|
self.irq_csr.wo(utra::irqarray1::EV_ENABLE, 0);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use api::*;
|
use api::*;
|
||||||
use bao1x_api::keyboard::KeyMap;
|
use bao1x_api::keyboard::KeyMap;
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
use bao1x_hal::axp2101::VbusIrq;
|
use bao1x_hal::axp2101::VbusIrq;
|
||||||
use bao1x_hal::usb::driver::{CorigineUsb, CorigineWrapper};
|
use bao1x_hal::usb::driver::{CorigineUsb, CorigineWrapper};
|
||||||
use hw::Bao1xUsb;
|
use hw::Bao1xUsb;
|
||||||
|
|
@ -59,10 +60,6 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn main_hw() -> ! {
|
pub(crate) fn main_hw() -> ! {
|
||||||
// confirm that the app UART is initialized in our PID - this needs to happen in a userspace call
|
|
||||||
// before any IRQ calls try to use it.
|
|
||||||
crate::println!("APP UART in PID {}", xous::process::id());
|
|
||||||
|
|
||||||
#[cfg(feature = "usbd-debug")]
|
#[cfg(feature = "usbd-debug")]
|
||||||
// bind the duart
|
// bind the duart
|
||||||
let duart_mapping = xous::syscall::map_memory(
|
let duart_mapping = xous::syscall::map_memory(
|
||||||
|
|
@ -263,12 +260,21 @@ pub(crate) fn main_hw() -> ! {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log::info!("Registering PMIC handler to detect USB plug/unplug events");
|
|
||||||
let iox = bao1x_api::IoxHal::new();
|
let iox = bao1x_api::IoxHal::new();
|
||||||
bao1x_hal::board::setup_pmic_irq(&iox, api::SERVER_NAME_USB_DEVICE, Opcode::PmicIrq.to_usize().unwrap());
|
#[cfg(feature = "board-baosec")]
|
||||||
let mut i2c = bao1x_hal_service::I2c::new();
|
let mut i2c = bao1x_hal_service::I2c::new();
|
||||||
let mut pmic = bao1x_hal::axp2101::Axp2101::new(&mut i2c).expect("couldn't open PMIC");
|
#[cfg(feature = "board-baosec")]
|
||||||
pmic.setup_vbus_irq(&mut i2c, bao1x_hal::axp2101::VbusIrq::Remove).expect("couldn't setup IRQ");
|
let pmic = {
|
||||||
|
log::info!("Registering PMIC handler to detect USB plug/unplug events");
|
||||||
|
bao1x_hal::board::setup_pmic_irq(
|
||||||
|
&iox,
|
||||||
|
api::SERVER_NAME_USB_DEVICE,
|
||||||
|
Opcode::PmicIrq.to_usize().unwrap(),
|
||||||
|
);
|
||||||
|
let mut pmic = bao1x_hal::axp2101::Axp2101::new(&mut i2c).expect("couldn't open PMIC");
|
||||||
|
pmic.setup_vbus_irq(&mut i2c, bao1x_hal::axp2101::VbusIrq::Remove).expect("couldn't setup IRQ");
|
||||||
|
pmic
|
||||||
|
};
|
||||||
|
|
||||||
let (se0_port, se0_pin) = bao1x_hal::board::setup_usb_pins(&iox);
|
let (se0_port, se0_pin) = bao1x_hal::board::setup_usb_pins(&iox);
|
||||||
iox.set_gpio_pin_value(se0_port, se0_pin, bao1x_api::IoxValue::High); // release SE0 state, allowing for enumeration
|
iox.set_gpio_pin_value(se0_port, se0_pin, bao1x_api::IoxValue::High); // release SE0 state, allowing for enumeration
|
||||||
|
|
@ -282,6 +288,7 @@ pub(crate) fn main_hw() -> ! {
|
||||||
let opcode = num_traits::FromPrimitive::from_usize(msg.body.id()).unwrap_or(Opcode::InvalidCall);
|
let opcode = num_traits::FromPrimitive::from_usize(msg.body.id()).unwrap_or(Opcode::InvalidCall);
|
||||||
log::debug!("{:?}", opcode);
|
log::debug!("{:?}", opcode);
|
||||||
match opcode {
|
match opcode {
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
Opcode::PmicIrq => match pmic.get_vbus_irq_status(&mut i2c).unwrap() {
|
Opcode::PmicIrq => match pmic.get_vbus_irq_status(&mut i2c).unwrap() {
|
||||||
VbusIrq::Insert => {
|
VbusIrq::Insert => {
|
||||||
log::error!("VBUS insert reported by PMIC, but we didn't ask for the event!");
|
log::error!("VBUS insert reported by PMIC, but we didn't ask for the event!");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue