mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-23 09:46:33 +11:00
Handle usb interrupt flags in driver (#106)
Set interrupt enable flags in USB driver. The flags were already being cleared in the USB driver. Update USB examples to remove interrupt flag set/check as it is no longer necessary.
This commit is contained in:
parent
c509b9d22f
commit
98b8e3ae9c
3 changed files with 12 additions and 60 deletions
|
@ -84,20 +84,6 @@ fn main() -> ! {
|
|||
USB_DEVICE = Some(usb_dev);
|
||||
}
|
||||
|
||||
// The USB driver doesn't enable key interrupts yet, so manually do that here
|
||||
unsafe {
|
||||
let p = pac::Peripherals::steal();
|
||||
// Enable interrupts for when a buffer is done, when the bus is reset,
|
||||
// and when a setup packet is received
|
||||
p.USBCTRL_REGS.inte.modify(|_, w| {
|
||||
w.buff_status()
|
||||
.set_bit()
|
||||
.bus_reset()
|
||||
.set_bit()
|
||||
.setup_req()
|
||||
.set_bit()
|
||||
});
|
||||
}
|
||||
// Enable the USB interrupt
|
||||
unsafe {
|
||||
pac::NVIC::unmask(hal::pac::Interrupt::USBCTRL_IRQ);
|
||||
|
@ -158,21 +144,4 @@ unsafe fn USBCTRL_IRQ() {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Clear pending interrupt flags here.
|
||||
// We could also move some of our code into these states to handle events
|
||||
let p = pac::Peripherals::steal();
|
||||
let status = &p.USBCTRL_REGS.sie_status;
|
||||
if status.read().ack_rec().bit_is_set() {
|
||||
status.modify(|_r, w| w.ack_rec().set_bit());
|
||||
}
|
||||
if status.read().setup_rec().bit_is_set() {
|
||||
status.modify(|_r, w| w.setup_rec().set_bit());
|
||||
}
|
||||
if status.read().trans_complete().bit_is_set() {
|
||||
status.modify(|_r, w| w.trans_complete().set_bit());
|
||||
}
|
||||
if status.read().bus_reset().bit_is_set() {
|
||||
status.modify(|_r, w| w.bus_reset().set_bit());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,19 +77,6 @@ fn main() -> ! {
|
|||
USB_DEVICE = Some(usb_dev);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let p = pac::Peripherals::steal();
|
||||
// Enable interrupts for when a buffer is done, when the bus is reset,
|
||||
// and when a setup packet is received
|
||||
p.USBCTRL_REGS.inte.modify(|_, w| {
|
||||
w.buff_status()
|
||||
.set_bit()
|
||||
.bus_reset()
|
||||
.set_bit()
|
||||
.setup_req()
|
||||
.set_bit()
|
||||
});
|
||||
}
|
||||
unsafe {
|
||||
pac::NVIC::unmask(hal::pac::Interrupt::USBCTRL_IRQ);
|
||||
};
|
||||
|
@ -133,20 +120,4 @@ unsafe fn USBCTRL_IRQ() {
|
|||
let usb_dev = USB_DEVICE.as_mut().unwrap();
|
||||
let usb_hid = USB_HID.as_mut().unwrap();
|
||||
usb_dev.poll(&mut [usb_hid]);
|
||||
|
||||
// Clear pending interrupt flags
|
||||
let p = pac::Peripherals::steal();
|
||||
let status = &p.USBCTRL_REGS.sie_status;
|
||||
if status.read().ack_rec().bit_is_set() {
|
||||
status.modify(|_r, w| w.ack_rec().set_bit());
|
||||
}
|
||||
if status.read().setup_rec().bit_is_set() {
|
||||
status.modify(|_r, w| w.setup_rec().set_bit());
|
||||
}
|
||||
if status.read().trans_complete().bit_is_set() {
|
||||
status.modify(|_r, w| w.trans_complete().set_bit());
|
||||
}
|
||||
if status.read().bus_reset().bit_is_set() {
|
||||
status.modify(|_r, w| w.bus_reset().set_bit());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -407,6 +407,18 @@ impl UsbBusTrait for UsbBus {
|
|||
// at this stage ep's are expected to be in their reset state
|
||||
// TODO: is it worth having a debug_assert for that here?
|
||||
|
||||
// Enable interrupt generation when a buffer is done, when the bus is reset,
|
||||
// and when a setup packet is received
|
||||
// this should be sufficient for device mode, will need more for host.
|
||||
inner.ctrl_reg.inte.modify(|_, w| {
|
||||
w.buff_status()
|
||||
.set_bit()
|
||||
.bus_reset()
|
||||
.set_bit()
|
||||
.setup_req()
|
||||
.set_bit()
|
||||
});
|
||||
|
||||
// enable pull up to let the host know we exist.
|
||||
inner
|
||||
.ctrl_reg
|
||||
|
|
Loading…
Add table
Reference in a new issue