mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add oem-baosec-lite support to usb driver
there is currently no method to detect USB power connect in this board. Considering adding a simple circuit to enable this. This design is not meant to be battery powered but it is possible that an aftermarket modification would introduce a battery, in which case, vbus detection does become A Thing.
This commit is contained in:
parent
bcf73733c3
commit
8b06b212bb
3 changed files with 11 additions and 8 deletions
|
|
@ -58,6 +58,7 @@ board-baosec = [
|
|||
"bao1x-hal",
|
||||
"bao1x-hal-service",
|
||||
]
|
||||
oem-baosec-lite = ["bao1x-hal/oem-baosec-lite"]
|
||||
board-dabao = ["utralib/bao1x", "utralib/std", "bao1x-hal", "bao1x-hal-service"]
|
||||
hosted-baosec = ["utralib/hosted", "utralib/std", "bao1x-emu"]
|
||||
# none of these other modes are actually supported, but are listed here
|
||||
|
|
|
|||
|
|
@ -87,14 +87,16 @@ impl<'a> Bao1xUsb<'a> {
|
|||
// to concurrently add that in - you have to kick out one of the interfaces above to add mass
|
||||
// storage!)
|
||||
|
||||
#[cfg(feature = "board-baosec")]
|
||||
#[cfg(feature = "oem-baosec-lite")]
|
||||
let product = "Baosec-lite";
|
||||
#[cfg(all(feature = "board-baosec", not(feature = "oem-baosec-lite")))]
|
||||
let product = "Baosec";
|
||||
#[cfg(feature = "board-baosec")]
|
||||
let pid = 0x6198; // pending PR acceptance
|
||||
let pid = 0x6198;
|
||||
#[cfg(feature = "board-dabao")]
|
||||
let product = "Dabao";
|
||||
#[cfg(feature = "board-dabao")]
|
||||
let pid = 0x6197; // pending PR acceptance
|
||||
let pid = 0x6197;
|
||||
let device = UsbDeviceBuilder::new(&usb_alloc, UsbVidPid(0x1d50, pid))
|
||||
.manufacturer("Baochip")
|
||||
.product(product)
|
||||
|
|
@ -160,7 +162,7 @@ impl<'a> Bao1xUsb<'a> {
|
|||
|
||||
/// 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")]
|
||||
#[cfg(all(feature = "board-baosec", not(feature = "oem-baosec-lite")))]
|
||||
pub fn unplug(&mut self) {
|
||||
// disable all interrupts so we can safely go through initialization routines
|
||||
self.irq_csr.wo(utra::irqarray1::EV_ENABLE, 0);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ pub(crate) fn main_hw() -> ! {
|
|||
use api::*;
|
||||
use bao1x_api::IoGpio;
|
||||
use bao1x_api::keyboard::KeyMap;
|
||||
#[cfg(feature = "board-baosec")]
|
||||
#[cfg(all(feature = "board-baosec", not(feature = "oem-baosec-lite")))]
|
||||
use bao1x_hal::axp2101::VbusIrq;
|
||||
use bao1x_hal::usb::driver::{CorigineUsb, CorigineWrapper};
|
||||
use hw::{Bao1xUsb, UsbIrqReq};
|
||||
|
|
@ -260,9 +260,9 @@ pub(crate) fn main_hw() -> ! {
|
|||
});
|
||||
|
||||
let iox = bao1x_api::IoxHal::new();
|
||||
#[cfg(feature = "board-baosec")]
|
||||
#[cfg(all(feature = "board-baosec", not(feature = "oem-baosec-lite")))]
|
||||
let mut i2c = bao1x_hal::i2c::I2c::new();
|
||||
#[cfg(feature = "board-baosec")]
|
||||
#[cfg(all(feature = "board-baosec", not(feature = "oem-baosec-lite")))]
|
||||
let pmic = {
|
||||
log::info!("Registering PMIC handler to detect USB plug/unplug events");
|
||||
bao1x_hal::board::setup_pmic_irq(
|
||||
|
|
@ -292,7 +292,7 @@ pub(crate) fn main_hw() -> ! {
|
|||
);
|
||||
}
|
||||
match opcode {
|
||||
#[cfg(feature = "board-baosec")]
|
||||
#[cfg(all(feature = "board-baosec", not(feature = "oem-baosec-lite")))]
|
||||
Opcode::PmicIrq => match pmic.get_vbus_irq_status(&mut i2c).unwrap() {
|
||||
VbusIrq::Insert => {
|
||||
log::error!("VBUS insert reported by PMIC, but we didn't ask for the event!");
|
||||
|
|
|
|||
Loading…
Reference in a new issue