summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2022-06-05 01:05:18 -0700
committerH. Peter Anvin <hpa@zytor.com>2022-06-05 01:05:18 -0700
commitc15e74f601276421573e4c46ac7448f93d742a5e (patch)
treec9e43999782d23314bf8c79afee90c0726045179
parent1b4255df8e36818aa1433607b4e827c280b2078b (diff)
downloadblinktest-c15e74f601276421573e4c46ac7448f93d742a5e.tar.gz
blinktest-c15e74f601276421573e4c46ac7448f93d742a5e.tar.xz
blinktest-c15e74f601276421573e4c46ac7448f93d742a5e.zip
rv32: add single-byte esplink get/put functions
For the single byte case, the esplink ring buffer get/put functions can be greatly simplified. This case matters e.g. when accessing a ring buffer from an ABC interrupt handler.
-rw-r--r--esp32/output/max80.ino.binbin774352 -> 774352 bytes
-rw-r--r--fpga/max80.qpf4
-rw-r--r--fpga/output/v1.fwbin735823 -> 735803 bytes
-rw-r--r--fpga/output/v1.jicbin16777443 -> 16777443 bytes
-rw-r--r--fpga/output/v1.rbf.gzbin160737 -> 160741 bytes
-rw-r--r--fpga/output/v1.rpd.gzbin217857 -> 217825 bytes
-rw-r--r--fpga/output/v1.sofbin509098 -> 509098 bytes
-rw-r--r--fpga/output/v1.svf.gzbin183565 -> 183559 bytes
-rw-r--r--fpga/output/v1.xsvf.gzbin165027 -> 165028 bytes
-rw-r--r--fpga/output/v2.fwbin735211 -> 735134 bytes
-rw-r--r--fpga/output/v2.jicbin16777443 -> 16777443 bytes
-rw-r--r--fpga/output/v2.rbf.gzbin160563 -> 160562 bytes
-rw-r--r--fpga/output/v2.rpd.gzbin217787 -> 217793 bytes
-rw-r--r--fpga/output/v2.sofbin509098 -> 509098 bytes
-rw-r--r--fpga/output/v2.svf.gzbin183313 -> 183310 bytes
-rw-r--r--fpga/output/v2.xsvf.gzbin164647 -> 164647 bytes
-rw-r--r--rv32/esp.c46
-rw-r--r--rv32/esplink.h2
18 files changed, 50 insertions, 2 deletions
diff --git a/esp32/output/max80.ino.bin b/esp32/output/max80.ino.bin
index ed218b5..ca258df 100644
--- a/esp32/output/max80.ino.bin
+++ b/esp32/output/max80.ino.bin
Binary files differ
diff --git a/fpga/max80.qpf b/fpga/max80.qpf
index 867d0c8..54026e6 100644
--- a/fpga/max80.qpf
+++ b/fpga/max80.qpf
@@ -19,12 +19,12 @@
#
# Quartus Prime
# Version 21.1.0 Build 842 10/21/2021 SJ Lite Edition
-# Date created = 00:47:37 June 05, 2022
+# Date created = 01:03:43 June 05, 2022
#
# -------------------------------------------------------------------------- #
QUARTUS_VERSION = "21.1"
-DATE = "00:47:37 June 05, 2022"
+DATE = "01:03:43 June 05, 2022"
# Revisions
diff --git a/fpga/output/v1.fw b/fpga/output/v1.fw
index 39dc305..ca04e7b 100644
--- a/fpga/output/v1.fw
+++ b/fpga/output/v1.fw
Binary files differ
diff --git a/fpga/output/v1.jic b/fpga/output/v1.jic
index 2530dab..1e18b6d 100644
--- a/fpga/output/v1.jic
+++ b/fpga/output/v1.jic
Binary files differ
diff --git a/fpga/output/v1.rbf.gz b/fpga/output/v1.rbf.gz
index 7118627..33d6ad0 100644
--- a/fpga/output/v1.rbf.gz
+++ b/fpga/output/v1.rbf.gz
Binary files differ
diff --git a/fpga/output/v1.rpd.gz b/fpga/output/v1.rpd.gz
index 3de5695..77638c2 100644
--- a/fpga/output/v1.rpd.gz
+++ b/fpga/output/v1.rpd.gz
Binary files differ
diff --git a/fpga/output/v1.sof b/fpga/output/v1.sof
index 0db7bd7..b2108fb 100644
--- a/fpga/output/v1.sof
+++ b/fpga/output/v1.sof
Binary files differ
diff --git a/fpga/output/v1.svf.gz b/fpga/output/v1.svf.gz
index 6131cd2..7fc722d 100644
--- a/fpga/output/v1.svf.gz
+++ b/fpga/output/v1.svf.gz
Binary files differ
diff --git a/fpga/output/v1.xsvf.gz b/fpga/output/v1.xsvf.gz
index fe316d2..4d4cbc4 100644
--- a/fpga/output/v1.xsvf.gz
+++ b/fpga/output/v1.xsvf.gz
Binary files differ
diff --git a/fpga/output/v2.fw b/fpga/output/v2.fw
index 7071281..8efb21e 100644
--- a/fpga/output/v2.fw
+++ b/fpga/output/v2.fw
Binary files differ
diff --git a/fpga/output/v2.jic b/fpga/output/v2.jic
index 7c07c5b..56a6986 100644
--- a/fpga/output/v2.jic
+++ b/fpga/output/v2.jic
Binary files differ
diff --git a/fpga/output/v2.rbf.gz b/fpga/output/v2.rbf.gz
index 2410ead..feb7d1f 100644
--- a/fpga/output/v2.rbf.gz
+++ b/fpga/output/v2.rbf.gz
Binary files differ
diff --git a/fpga/output/v2.rpd.gz b/fpga/output/v2.rpd.gz
index cc631cf..523cbbe 100644
--- a/fpga/output/v2.rpd.gz
+++ b/fpga/output/v2.rpd.gz
Binary files differ
diff --git a/fpga/output/v2.sof b/fpga/output/v2.sof
index 75390f4..f5b9ea3 100644
--- a/fpga/output/v2.sof
+++ b/fpga/output/v2.sof
Binary files differ
diff --git a/fpga/output/v2.svf.gz b/fpga/output/v2.svf.gz
index e2ed4a9..862a0aa 100644
--- a/fpga/output/v2.svf.gz
+++ b/fpga/output/v2.svf.gz
Binary files differ
diff --git a/fpga/output/v2.xsvf.gz b/fpga/output/v2.xsvf.gz
index a2e9614..76869dc 100644
--- a/fpga/output/v2.xsvf.gz
+++ b/fpga/output/v2.xsvf.gz
Binary files differ
diff --git a/rv32/esp.c b/rv32/esp.c
index f070490..262d6e3 100644
--- a/rv32/esp.c
+++ b/rv32/esp.c
@@ -159,6 +159,52 @@ size_t esp_rb_write(enum esplink_ringbuf_user ring,
return len;
}
+/*
+ * Faster/simpler versions for reading/writing a single byte at a time;
+ * esp_rb_getc() returns -1 if the ring is empty.
+ *
+ * esp_rb_putc() returns -1 on failure, otherwise the number of
+ * bytes still free in the ring (a nonnegative number.)
+ */
+int esp_rb_getc(enum esplink_ringbuf_user ring)
+{
+ const size_t size = rb_desc[ring].dstr.size;
+ const size_t sizemask = size - 1;
+ const uint8_t * const base = rb_desc[ring].dstr.start;
+ size_t head = rb_ustr[ring].head;
+ size_t tail = rb_dstr[ring].tail;
+ int data;
+
+ if (tail == head)
+ return -1; /* Buffer empty */
+
+ data = base[tail];
+ tail = (tail + 1) & sizemask;
+ rb_dstr[ring].tail = tail;
+ ESP_SPI_IRQ_SET = 1 << EL_UIRQ_RINGBUF;
+
+ return data;
+}
+
+int esp_rb_putc(enum esplink_ringbuf_user ring, uint8_t data)
+{
+ const size_t size = rb_desc[ring].ustr.size;
+ const size_t sizemask = size - 1;
+ uint8_t * const base = rb_desc[ring].ustr.start;
+ size_t tail = rb_ustr[ring].tail;
+ size_t head = rb_dstr[ring].head;
+ int avail = (tail - head - 1) & sizemask;
+
+ if (avail--) {
+ base[head] = data;
+ head = (head + 1) & sizemask;
+ rb_dstr[ring].head = head;
+ ESP_SPI_IRQ_SET = 1 << EL_UIRQ_RINGBUF;
+ }
+
+ return avail;
+}
+
void esp_init(void)
{
static char __dram_data esp_signature[] = "Hej tomtebuggar slÄ i glasen!";
diff --git a/rv32/esplink.h b/rv32/esplink.h
index 3c78318..c9edad4 100644
--- a/rv32/esplink.h
+++ b/rv32/esplink.h
@@ -10,5 +10,7 @@ extern size_t esp_rb_read(enum esplink_ringbuf_user ring,
void *data, size_t len);
extern size_t esp_rb_write(enum esplink_ringbuf_user ring,
const void *data, size_t len);
+extern int esp_rb_getc(enum esplink_ringbuf_user ring);
+extern int esp_rb_putc(enum esplink_ringbuf_user ring, uint8_t data);
#endif /* RV32_ESPLINK_H */