mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
add a test loop to check the IRQ pin configuration
this all seems to work as expected now, next up: hooking the interrupt handler for the IOX. Probably should put the actual IRQ router in the HAL so that multiple services can configure it, but have the handler actually invoke a function in our address space.
This commit is contained in:
parent
19780161bb
commit
2090288009
1 changed files with 27 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use api::{HIDReport, LogLevel, Opcode, U2fCode, U2fMsgIpc, UsbListenerRegistration};
|
use api::{HIDReport, LogLevel, Opcode, U2fCode, U2fMsgIpc, UsbListenerRegistration};
|
||||||
use cram_hal_service::api::KeyMap;
|
use cram_hal_service::api::KeyMap;
|
||||||
|
use cramium_hal::axp2101::VbusIrq;
|
||||||
use cramium_hal::usb::driver::{CorigineUsb, CorigineWrapper};
|
use cramium_hal::usb::driver::{CorigineUsb, CorigineWrapper};
|
||||||
use hw::CramiumUsb;
|
use hw::CramiumUsb;
|
||||||
use hw::UsbIrqReq;
|
use hw::UsbIrqReq;
|
||||||
|
|
@ -239,6 +240,32 @@ pub(crate) fn main_hw() -> ! {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
std::thread::spawn({
|
||||||
|
move || {
|
||||||
|
log::info!("Connecting to I2C");
|
||||||
|
let mut i2c = cram_hal_service::I2c::new();
|
||||||
|
let mut pmic = cramium_hal::axp2101::Axp2101::new(&mut i2c).expect("couldn't open PMIC");
|
||||||
|
let iox = cram_hal_service::IoxHal::new();
|
||||||
|
log::info!("AXP2101 config: {:?}", pmic);
|
||||||
|
let tt = ticktimer::Ticktimer::new().unwrap();
|
||||||
|
pmic.setup_vbus_irq(&mut i2c, cramium_hal::axp2101::VbusIrq::InsertAndRemove)
|
||||||
|
.expect("couldn't setup IRQ");
|
||||||
|
// PB13 is the IRQ input
|
||||||
|
loop {
|
||||||
|
tt.sleep_ms(500).ok();
|
||||||
|
let status = pmic.get_vbus_irq_status(&mut i2c).unwrap();
|
||||||
|
log::info!(
|
||||||
|
"Status: {:?}, {:?}",
|
||||||
|
status,
|
||||||
|
iox.get_gpio_pin_value(cramium_hal::iox::IoxPort::PB, 13)
|
||||||
|
);
|
||||||
|
if status != VbusIrq::None {
|
||||||
|
pmic.clear_vbus_irq_pending(&mut i2c).expect("couldn't clear pending VBUS IRQ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
log::info!("Entering main loop");
|
log::info!("Entering main loop");
|
||||||
|
|
||||||
let mut msg_opt = None;
|
let mut msg_opt = None;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue