summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve/eve.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-05-13 12:26:19 +0200
committerUros Majstorovic <majstor@majstor.org>2022-05-13 12:26:19 +0200
commit9ccb4db8d59ec9dab33ee8617d462f21a8bb4fa8 (patch)
treea4f8ba9375a4ee82bae6ddc0cb3a35227f6f9469 /fw/fe310/eos/eve/eve.c
parent45f0d9b890b086493f9bb06428c46cd802324223 (diff)
touch controller/eve fixes
Diffstat (limited to 'fw/fe310/eos/eve/eve.c')
-rw-r--r--fw/fe310/eos/eve/eve.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c
index e1191fc..02e0cae 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(uint8_t gpio_dir) {
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;
@@ -381,21 +383,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 +414,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 +427,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 +438,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 +449,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 +476,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;
+}