summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve/eve.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/eve/eve.c')
-rw-r--r--fw/fe310/eos/eve/eve.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c
index e1191fc..5103e5f 100644
--- a/fw/fe310/eos/eve/eve.c
+++ b/fw/fe310/eos/eve/eve.c
@@ -13,6 +13,7 @@ static char dl_burst;
static uint32_t dl_addr;
static uint8_t power_state;
+static int lcd_absent = 0;
void eve_command(uint8_t command, uint8_t parameter) {
eve_spi_cs_set();
@@ -289,6 +290,7 @@ int eve_cmd_exec(int w) {
void eve_cmd_burst_start(void) {
uint32_t addr = EVE_RAM_CMD + cmd_offset;
+
eve_spi_lock();
eve_spi_cs_set();
eve_spi_xchg24(addr | EVE_MEM_WRITE, EVE_SPI_FLAG_TX);
@@ -306,10 +308,10 @@ void eve_handle_intr(void) {
uint16_t intr_flags;
intr_flags = eve_read16(REG_INT_FLAGS);
- eve_handle_touch(intr_flags);
+ if (intr_flags & (EVE_INT_CONVCOMPLETE | EVE_INT_TAG)) eve_handle_touch(intr_flags);
}
-int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
+int eve_init(void) {
uint8_t chipid = 0;
uint8_t reset = 0x07;
uint16_t timeout;
@@ -319,11 +321,11 @@ int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
eve_command(EVE_CLKEXT, 0);
eve_command(EVE_CLKSEL, 0x46); /* set clock to 72 MHz */
eve_command(EVE_ACTIVE, 0); /* start EVE */
- eve_time_sleep(4);
+ eve_sleep(4);
timeout = 0;
while (chipid != 0x7c) { /* if chipid is not 0x7c, continue to read it until it is, EVE needs a moment for it's power on self-test and configuration */
- eve_time_sleep(1);
+ eve_sleep(1);
chipid = eve_read8(REG_ID);
timeout++;
if (timeout > 400) return EVE_ERR;
@@ -331,7 +333,7 @@ int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
timeout = 0;
while (reset != 0x00) { /* check if EVE is in working status */
- eve_time_sleep(1);
+ eve_sleep(1);
reset = eve_read8(REG_CPURESET) & 0x07;
timeout++;
if(timeout > 50) return EVE_ERR;
@@ -341,7 +343,7 @@ int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
eve_write8(REG_PWM_DUTY, 0x00);
eve_write16(REG_GPIOX, 0x0000);
- eve_write16(REG_GPIOX_DIR, 0x8000 | (gpio_dir & 0x0f));
+ eve_write16(REG_GPIOX_DIR, 0x8000);
/* initialize display */
eve_write16(REG_HCYCLE, EVE_HCYCLE); /* total number of clocks per line, incl front/back porch */
@@ -361,7 +363,8 @@ int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
/* do not set PCLK yet - wait for just after the first display list */
/* disable audio */
- eve_write16(REG_SOUND, 0x0000); /* set synthesizer to silence */
+ eve_write16(REG_SOUND, 0x0060); /* set synthesizer to mute */
+ eve_write8(REG_PLAY, 0x01);
eve_write8(REG_VOL_SOUND, 0x00); /* turn synthesizer volume off */
eve_write8(REG_VOL_PB, 0x00); /* turn recorded audio volume off */
@@ -381,21 +384,16 @@ int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
#endif
/* nothing is being displayed yet... the pixel clock is still 0x00 */
- eve_touch_init(touch_calibrate, touch_matrix);
return EVE_OK;
}
void eve_start(void) {
- eve_touch_start();
-
/* enable interrupts */
eve_write8(REG_INT_EN, 0x01);
while(eve_read8(REG_INT_FLAGS));
}
void eve_stop(void) {
- eve_touch_stop();
-
/* disable interrupts */
eve_write8(REG_INT_EN, 0x00);
while(eve_read8(REG_INT_FLAGS));
@@ -417,12 +415,12 @@ void eve_stop_clk(void) {
eve_write8(REG_PCLK, 0);
}
-void eve_active(void) {
+void eve_activate(void) {
eve_command(EVE_ACTIVE, 0);
- eve_time_sleep(40);
+ eve_sleep(40);
}
-void eve_standby(void) {
+void eve_pwr_standby(void) {
if (power_state != EVE_PSTATE_ACTIVE) return;
eve_command(EVE_STANDBY, 0);
@@ -430,7 +428,7 @@ void eve_standby(void) {
power_state = EVE_PSTATE_STANDBY;
}
-void eve_sleep(void) {
+void eve_pwr_sleep(void) {
if (power_state != EVE_PSTATE_ACTIVE) return;
eve_stop_clk();
@@ -441,8 +439,8 @@ void eve_sleep(void) {
power_state = EVE_PSTATE_SLEEP;
}
-void eve_wake(void) {
- eve_active();
+void eve_pwr_wake(void) {
+ eve_activate();
if (power_state == EVE_PSTATE_SLEEP) {
eve_start();
@@ -452,10 +450,6 @@ void eve_wake(void) {
power_state = EVE_PSTATE_ACTIVE;
}
-void eve_brightness(uint8_t b) {
- eve_write8(REG_PWM_DUTY, b);
-}
-
int eve_gpio_get(int gpio) {
uint16_t reg = eve_read16(REG_GPIOX);
@@ -483,3 +477,12 @@ void eve_gpio_set_dir(uint8_t dir) {
reg |= dir & 0x0f;
eve_write16(REG_GPIOX_DIR, reg);
}
+
+void eve_brightness(uint8_t b) {
+ if (lcd_absent) b = 0;
+ eve_write8(REG_PWM_DUTY, b);
+}
+
+void eve_lcd_absent(void) {
+ lcd_absent = 1;
+}