summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--code/fe310/eos/eve/Makefile17
-rw-r--r--code/fe310/eos/eve/eve_platform.c69
-rw-r--r--code/fe310/eos/eve/eve_platform.h23
3 files changed, 109 insertions, 0 deletions
diff --git a/code/fe310/eos/eve/Makefile b/code/fe310/eos/eve/Makefile
new file mode 100644
index 0000000..5fd619a
--- /dev/null
+++ b/code/fe310/eos/eve/Makefile
@@ -0,0 +1,17 @@
+include ../../common.mk
+
+CFLAGS += -I.. -I../../include -I../../drivers
+
+obj = eve.o eve_kbd.o eve_text.o eve_platform.o
+
+
+%.o: %.c %.h
+ $(CC) $(CFLAGS) -c $<
+
+%.o: %.S
+ $(CC) $(CFLAGS) -c $<
+
+all: $(obj)
+
+clean:
+ rm -f *.o \ No newline at end of file
diff --git a/code/fe310/eos/eve/eve_platform.c b/code/fe310/eos/eve/eve_platform.c
new file mode 100644
index 0000000..e15d414
--- /dev/null
+++ b/code/fe310/eos/eve/eve_platform.c
@@ -0,0 +1,69 @@
+#include <stdlib.h>
+
+#include "encoding.h"
+#include "platform.h"
+
+#include "eos.h"
+#include "interrupt.h"
+#include "event.h"
+#include "timer.h"
+#include "spi.h"
+#include "eve.h"
+#include "eve_platform.h"
+
+#include "irq_def.h"
+
+#define EVE_PIN_INTR 0
+
+static void handle_time(unsigned char type) {
+ eos_spi_dev_start(EOS_DEV_DISP);
+ eve_handle_time();
+ eos_spi_dev_stop();
+}
+
+static void handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
+ uint8_t flags;
+
+ eos_spi_dev_start(EOS_DEV_DISP);
+ eve_handle_touch();
+ eos_spi_dev_stop();
+
+ GPIO_REG(GPIO_LOW_IP) = (1 << EVE_PIN_INTR);
+ GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR);
+}
+
+static void handle_intr(void) {
+ GPIO_REG(GPIO_LOW_IE) &= ~(1 << EVE_PIN_INTR);
+ eos_evtq_push_isr(EOS_EVT_UI | EVE_ETYPE_INTR, NULL, 0);
+ return;
+}
+
+void eve_sleep(uint32_t ms) {
+ eos_timer_sleep(ms);
+}
+
+void eve_timer_set(uint32_t ms) {
+ eos_timer_set(ms, EOS_TIMER_ETYPE_UI, 0);
+}
+
+void eve_timer_clear(void) {
+ eos_timer_clear(EOS_TIMER_ETYPE_UI);
+}
+
+uint64_t eve_timer_get_tick(void) {
+ volatile uint64_t *mtime = (uint64_t *) (CLINT_CTRL_ADDR + CLINT_MTIME);
+ return *mtime;
+}
+
+void eve_init_platform(void) {
+ eos_evtq_set_handler(EOS_EVT_UI, handle_evt);
+ eos_timer_set_handler(EOS_TIMER_ETYPE_UI, handle_time);
+
+ GPIO_REG(GPIO_INPUT_EN) |= (1 << EVE_PIN_INTR);
+ GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << EVE_PIN_INTR);
+ GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << EVE_PIN_INTR);
+ GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << EVE_PIN_INTR);
+
+ GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR);
+ eos_intr_set(INT_GPIO_BASE + EVE_PIN_INTR, IRQ_PRIORITY_UI, handle_intr);
+} \ No newline at end of file
diff --git a/code/fe310/eos/eve/eve_platform.h b/code/fe310/eos/eve/eve_platform.h
new file mode 100644
index 0000000..8ab43ea
--- /dev/null
+++ b/code/fe310/eos/eve/eve_platform.h
@@ -0,0 +1,23 @@
+#include <stdint.h>
+
+#include "spi.h"
+
+#define EVE_RTC_FREQ 32768
+
+#define EVE_SPI_FLAG_BSWAP EOS_SPI_FLAG_BSWAP
+#define EVE_SPI_FLAG_TX EOS_SPI_FLAG_TX
+
+#define eve_spi_cs_set eos_spi_cs_set
+#define eve_spi_cs_clear eos_spi_cs_clear
+#define eve_spi_flush eos_spi_flush
+#define eve_spi_xchg8 eos_spi_xchg8
+#define eve_spi_xchg16 eos_spi_xchg16
+#define eve_spi_xchg24 eos_spi_xchg24
+#define eve_spi_xchg32 eos_spi_xchg32
+
+void eve_sleep(uint32_t ms);
+void eve_timer_set(uint32_t ms);
+void eve_timer_clear(void);
+uint64_t eve_timer_get_tick(void);
+
+void eve_init_platform(void); \ No newline at end of file