icE1usb fw: Misc cosmetic cleanup in e1.{c,h} / usb_e1.c
Moving things around, comments, spacing, ... nothing functional.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Icc2a6ef6b03c89dd92e661a01d219e42dbf7067d
diff --git a/firmware/ice40-riscv/icE1usb/e1.c b/firmware/ice40-riscv/icE1usb/e1.c
index 59be063..6a4c73c 100644
--- a/firmware/ice40-riscv/icE1usb/e1.c
+++ b/firmware/ice40-riscv/icE1usb/e1.c
@@ -18,9 +18,16 @@
#include "led.h" // FIXME
+// HW access
+// ---------
+
static volatile struct e1_core * const e1_regs = (void *)(E1_CORE_BASE);
static volatile uint8_t * const e1_data = (void *)(E1_DATA_BASE);
+
+// Helpers
+// -------
+
static unsigned int
e1_data_ofs(int mf, int frame, int ts)
{
@@ -33,6 +40,7 @@
return &e1_data[e1_data_ofs(mf, frame, ts)];
}
+
// FIFOs
// -----
/* Note: FIFO works at 'frame' level (i.e. 32 bytes) */
@@ -98,7 +106,6 @@
return (ofs >> 4);
}
-
/* Debug */
static void
e1f_debug(struct e1_fifo *fifo, const char *name)
@@ -207,7 +214,6 @@
}
-
// Main logic
// ----------
@@ -232,12 +238,11 @@
int in_flight;
enum e1_pipe_state state;
} tx;
+
struct e1_error_count errors;
} g_e1;
-
-
void
e1_init(uint16_t rx_cr, uint16_t tx_cr)
{
@@ -285,8 +290,6 @@
e1_regs->rx.csr = g_e1.rx.cr;
}
-#include "dma.h"
-
unsigned int
e1_rx_need_data(unsigned int usb_addr, unsigned int max_frames, unsigned int *pos)
{
diff --git a/firmware/ice40-riscv/icE1usb/e1.h b/firmware/ice40-riscv/icE1usb/e1.h
index 4cbb6e5..9ceffdd 100644
--- a/firmware/ice40-riscv/icE1usb/e1.h
+++ b/firmware/ice40-riscv/icE1usb/e1.h
@@ -7,6 +7,9 @@
#pragma once
+
+/* control */
+
void e1_init(uint16_t rx_cr, uint16_t tx_cr);
void e1_poll(void);
void e1_debug_print(bool data);
@@ -14,6 +17,17 @@
void e1_tx_config(uint16_t cr);
void e1_rx_config(uint16_t cr);
+
+/* data flow */
+
+unsigned int e1_rx_need_data(unsigned int usb_addr, unsigned int max_len, unsigned int *pos);
+unsigned int e1_tx_feed_data(unsigned int usb_addr, unsigned int len);
+unsigned int e1_tx_level(void);
+unsigned int e1_rx_level(void);
+
+
+/* error reporting */
+
#define E1_ERR_F_ALIGN_ERR 0x01
#define E1_ERR_F_LOS 0x02
#define E1_ERR_F_RAI 0x04
@@ -28,6 +42,9 @@
const struct e1_error_count *e1_get_error_count(void);
+
+/* external function provided by the platform; used by E1 driver to control LEDs */
+
enum e1_platform_led {
E1P_LED_GREEN = 0,
E1P_LED_YELLOW = 1,
@@ -40,6 +57,5 @@
E1P_LED_ST_BLINK_FAST = 3
};
-/* external function provided by the platform; used by E1 driver to control LEDs */
extern void e1_platform_led_set(uint8_t port, enum e1_platform_led led,
enum e1_platform_led_state state);
diff --git a/firmware/ice40-riscv/icE1usb/usb_e1.c b/firmware/ice40-riscv/icE1usb/usb_e1.c
index b4d8839..34ade71 100644
--- a/firmware/ice40-riscv/icE1usb/usb_e1.c
+++ b/firmware/ice40-riscv/icE1usb/usb_e1.c
@@ -15,7 +15,6 @@
#include "console.h"
#include "misc.h"
#include "e1.h"
-#include "e1_hw.h"
#include "ice1usb_proto.h"
@@ -41,13 +40,6 @@
};
-/* Hack */
-unsigned int e1_rx_need_data(unsigned int usb_addr, unsigned int max_len, unsigned int *pos);
-unsigned int e1_tx_feed_data(unsigned int usb_addr, unsigned int len);
-unsigned int e1_tx_level(void);
-unsigned int e1_rx_level(void);
-/* ---- */
-
static void
_usb_fill_feedback_ep(void)
{