summaryrefslogtreecommitdiff
path: root/fw
diff options
context:
space:
mode:
Diffstat (limited to 'fw')
-rw-r--r--fw/fe310/eos/dev/eve.c36
-rw-r--r--fw/fe310/eos/dev/sdcard.c4
-rw-r--r--fw/fe310/eos/eve/eve_platform.c8
-rw-r--r--fw/fe310/eos/eve/eve_platform.h5
4 files changed, 30 insertions, 23 deletions
diff --git a/fw/fe310/eos/dev/eve.c b/fw/fe310/eos/dev/eve.c
index 0f98fed..b46e045 100644
--- a/fw/fe310/eos/dev/eve.c
+++ b/fw/fe310/eos/dev/eve.c
@@ -20,17 +20,17 @@
static void handle_time(unsigned char type) {
if (!eos_eve_running()) return;
- eve_spi_start();
+ eve_select();
eve_handle_time();
- eve_spi_stop();
+ eve_deselect();
}
static void handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
if (!eos_eve_running()) return;
- eve_spi_start();
+ eve_select();
eve_handle_intr();
- eve_spi_stop();
+ eve_deselect();
GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR);
}
@@ -65,7 +65,7 @@ int eos_eve_init(uint8_t wakeup_cause) {
int rst = (wakeup_cause == EOS_PWR_WAKE_RST);
int rv = EVE_OK;
- eve_spi_start();
+ eve_select();
if (rst) {
rv = eve_init();
if (!rv) {
@@ -75,7 +75,7 @@ int eos_eve_init(uint8_t wakeup_cause) {
} else {
eve_activate();
}
- eve_spi_stop();
+ eve_deselect();
if (rv) return EOS_ERR;
@@ -93,7 +93,7 @@ void eos_eve_calibrate(void) {
uint32_t matrix[6];
int r;
- eve_spi_start();
+ eve_select();
eve_brightness(0x40);
eve_touch_set_extended(0);
@@ -105,46 +105,46 @@ void eos_eve_calibrate(void) {
do {
r = eve_cmd_done();
if (r < 0) break;
- eve_spi_stop();
+ eve_deselect();
eos_evtq_exec();
- eve_spi_start();
+ eve_select();
} while (!r);
eve_touch_set_extended(1);
eve_brightness(0);
eve_touch_get_matrix(matrix);
- eve_spi_stop();
+ eve_deselect();
printf("TOUCH MATRIX:\n");
printf("uint32_t touch_matrix[6] = {0x%x,0x%x,0x%x,0x%x,0x%x,0x%x}\n", matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
}
void eos_eve_set_touch_matrix(const uint32_t *matrix) {
- eve_spi_start();
+ eve_select();
eve_touch_set_matrix(matrix);
- eve_spi_stop();
+ eve_deselect();
}
int eos_eve_run(uint8_t wakeup_cause) {
- eve_spi_start();
+ eve_select();
_start();
eve_start_clk();
- eve_spi_stop();
+ eve_deselect();
return EOS_OK;
}
void eos_eve_start(void) {
- eve_spi_start();
+ eve_select();
_start();
- eve_spi_stop();
+ eve_deselect();
}
void eos_eve_stop(void) {
- eve_spi_start();
+ eve_select();
_stop();
- eve_spi_stop();
+ eve_deselect();
}
int eos_eve_running(void) {
diff --git a/fw/fe310/eos/dev/sdcard.c b/fw/fe310/eos/dev/sdcard.c
index fa316c7..656d27a 100644
--- a/fw/fe310/eos/dev/sdcard.c
+++ b/fw/fe310/eos/dev/sdcard.c
@@ -355,7 +355,9 @@ static int sdc_init(uint32_t timeout) {
int eos_sdc_init(uint8_t wakeup_cause) {
int rv;
- eos_spi_select(EOS_SPI_DEV_SDC);
+ rv = eos_spi_select(EOS_SPI_DEV_SDC);
+ if (rv) return rv;
+
rv = sdc_init(5000);
if (rv) {
printf("SDC ERROR\n");
diff --git a/fw/fe310/eos/eve/eve_platform.c b/fw/fe310/eos/eve/eve_platform.c
index f0fc399..a57281c 100644
--- a/fw/fe310/eos/eve/eve_platform.c
+++ b/fw/fe310/eos/eve/eve_platform.c
@@ -33,10 +33,14 @@ void eve_sys_timer_clear(void) {
eos_timer_clear(EOS_TIMER_ETYPE_UI);
}
-void eve_spi_start(void) {
+void eve_select(void) {
eos_spi_select(EOS_SPI_DEV_EVE);
}
-void eve_spi_stop(void) {
+void eve_deselect(void) {
eos_spi_deselect();
}
+
+int eve_selected(void) {
+ return (eos_spi_dev() == EOS_SPI_DEV_EVE);
+}
diff --git a/fw/fe310/eos/eve/eve_platform.h b/fw/fe310/eos/eve/eve_platform.h
index 29240d5..cae7222 100644
--- a/fw/fe310/eos/eve/eve_platform.h
+++ b/fw/fe310/eos/eve/eve_platform.h
@@ -18,8 +18,9 @@ void eve_free(void *);
//#define eve_malloc malloc
//#define eve_free free
-void eve_spi_start(void);
-void eve_spi_stop(void);
+void eve_select(void);
+void eve_deselect(void);
+int eve_selected(void);
#define eve_spi_cs_set eos_spi_cs_set
#define eve_spi_cs_clear eos_spi_cs_clear