icE1usb fw: Have usb_e1 handle the E1 polling and multi port
The init already takes care of both port and also calling
e1_init, so it makes sense to have a usb_e1_poll() that
encapsulate both the actual e1 hardware poll and running
the usb stuff for both port.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Icf81efcdc5c8f13480ba2652bc6e7c1ca226ae4d
diff --git a/firmware/ice40-riscv/icE1usb/fw_app.c b/firmware/ice40-riscv/icE1usb/fw_app.c
index 5e9812c..3fbec7c 100644
--- a/firmware/ice40-riscv/icE1usb/fw_app.c
+++ b/firmware/ice40-riscv/icE1usb/fw_app.c
@@ -158,9 +158,6 @@
usb_poll();
/* E1 poll */
- for (int port=0; port<2; port++) {
- e1_poll(port);
- usb_e1_run(port);
- }
+ usb_e1_poll();
}
}
diff --git a/firmware/ice40-riscv/icE1usb/usb_e1.c b/firmware/ice40-riscv/icE1usb/usb_e1.c
index 96ca72a..5d32924 100644
--- a/firmware/ice40-riscv/icE1usb/usb_e1.c
+++ b/firmware/ice40-riscv/icE1usb/usb_e1.c
@@ -96,8 +96,8 @@
}
-void
-usb_e1_run(int port)
+static void
+_usb_e1_run(int port)
{
struct usb_e1_state *usb_e1 = _get_state(port);
volatile struct usb_ep *ep_regs;
@@ -210,6 +210,16 @@
_usb_fill_feedback_ep(port);
}
+void
+usb_e1_poll(void)
+{
+ for (int i=0; i<2; i++) {
+ e1_poll(i);
+ _usb_e1_run(i);
+ }
+}
+
+
static enum usb_fnd_resp
_e1_set_conf(const struct usb_conf_desc *conf)
{
diff --git a/firmware/ice40-riscv/icE1usb/usb_e1.h b/firmware/ice40-riscv/icE1usb/usb_e1.h
index 06723ea..65ebb61 100644
--- a/firmware/ice40-riscv/icE1usb/usb_e1.h
+++ b/firmware/ice40-riscv/icE1usb/usb_e1.h
@@ -7,5 +7,5 @@
#pragma once
-void usb_e1_run(int port);
+void usb_e1_poll(void);
void usb_e1_init(void);