summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eos.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/eos.c')
-rw-r--r--fw/fe310/eos/eos.c111
1 files changed, 72 insertions, 39 deletions
diff --git a/fw/fe310/eos/eos.c b/fw/fe310/eos/eos.c
index 6df8700..73ab29c 100644
--- a/fw/fe310/eos/eos.c
+++ b/fw/fe310/eos/eos.c
@@ -3,10 +3,12 @@
#include "encoding.h"
#include "platform.h"
#include "prci_driver.h"
+#include "board.h"
#include "event.h"
#include "soc/interrupt.h"
#include "soc/timer.h"
+#include "soc/aon.h"
#include "soc/pwr.h"
#include "soc/i2s.h"
#include "soc/i2c.h"
@@ -16,18 +18,20 @@
#include "dev/flash.h"
#include "dev/spi.h"
#include "dev/net.h"
+#include "dev/egpio.h"
+#include "dev/egpio_priv.h"
#include "dev/lcd.h"
+#include "dev/ctp.h"
#include "dev/sdcard.h"
-#include "dev/gt911.h"
-#include "dev/bq25895.h"
+#include "dev/batt.h"
#include "dev/eve.h"
-#include "net/pwr.h"
#include "net/wifi.h"
#include "net/sock.h"
#include "net/cell.h"
#include "eos.h"
+#include "log.h"
uint8_t eos_init(void) {
uint8_t wakeup_cause;
@@ -36,65 +40,94 @@ uint8_t eos_init(void) {
PRCI_use_default_clocks();
PRCI_use_pll(PLL_REFSEL_HFXOSC, 0, 1, 31, 1, -1, -1, -1);
+ /* enable printf */
+ eos_uart_preinit();
+ /* set flash driver */
eos_flash_init();
wakeup_cause = eos_pwr_wakeup_cause();
- eos_evtq_init(wakeup_cause);
- eos_intr_init(wakeup_cause);
- eos_timer_init(wakeup_cause);
- eos_uart_init(wakeup_cause);
+ EOS_LOG(EOS_LOG_INFO, "INIT:%d\n", wakeup_cause);
+ EOS_LOG(EOS_LOG_INFO, "FREQ:%lu\n", PRCI_get_cpu_freq());
- printf("INIT:%d\n", wakeup_cause);
+ rv = eos_evtq_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "EVTQ INIT ERR:%d\n", rv);
+ rv = eos_intr_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "INTR INIT ERR:%d\n", rv);
+ rv = eos_timer_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "TIMER INIT ERR:%d\n", rv);
- rv = eos_pwr_init(wakeup_cause);
- if (rv) printf("PWR INIT ERR:%d\n", rv);
- rv = eos_i2s_init(wakeup_cause);
- if (rv) printf("I2S INIT ERR:%d\n", rv);
- rv = eos_i2c_init(wakeup_cause);
- if (rv) printf("I2C INIT ERR:%d\n", rv);
- rv = eos_spi_init(wakeup_cause);
- if (rv) printf("SPI INIT ERR:%d\n", rv);
- rv = eos_spi_dev_init(wakeup_cause);
- if (rv) printf("SPI DEV INIT ERR:%d\n", rv);
+ rv = eos_aon_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "AON INIT ERR:%d\n", rv);
+ rv = eos_pwr_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "PWR INIT ERR:%d\n", rv);
+ rv = eos_uart_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "UART INIT ERR:%d\n", rv);
- rv = eos_bq25895_init(wakeup_cause);
- if (rv) printf("BQ25895 INIT ERR:%d\n", rv);
+ rv = eos_i2s_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "I2S INIT ERR:%d\n", rv);
+ rv = eos_i2c_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "I2C INIT ERR:%d\n", rv);
- rv = eos_net_init(wakeup_cause);
- if (rv) printf("NET INIT ERR:%d\n", rv);
+ rv = eos_egpio_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "EGPIO INIT ERR:%d\n", rv);
- rv = eos_sdc_init(wakeup_cause);
- if (rv) printf("SDC INIT ERR:%d\n", rv);
+ rv = eos_batt_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "BATT INIT ERR:%d\n", rv);
- rv = eos_eve_init(wakeup_cause);
- if (rv) printf("EVE INIT ERR:%d\n", rv);
+ rv = eos_spi_dev_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "SPI DEV INIT ERR:%d\n", rv);
+ rv = eos_spi_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "SPI INIT ERR:%d\n", rv);
+ rv = eos_sdc_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "SDC INIT ERR:%d\n", rv);
- rv = eos_lcd_init(wakeup_cause);
- if (rv) printf("LCD INIT ERR:%d\n", rv);
+ rv = eos_eve_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "EVE INIT ERR:%d\n", rv);
- rv = eos_eve_run(wakeup_cause);
- if (rv) printf("EVE RUN ERR:%d\n", rv);
+ rv = eos_lcd_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "LCD INIT ERR:%d\n", rv);
+
+ rv = eos_ctp_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "CTP INIT ERR:%d\n", rv);
+
+ rv = eos_net_init();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "NET INIT ERR:%d\n", rv);
- eos_pwr_net_init();
eos_wifi_init();
eos_sock_init();
eos_cell_init();
+ rv = eos_sdc_insert(!eos_egpio_get_val(EGPIO_PIN_SDCARD_NDET), 0);
+ if (rv) EOS_LOG(EOS_LOG_ERR, "SDC INSERT ERR:%d\n", rv);
+
return wakeup_cause;
}
-void eos_run(uint8_t wakeup_cause) {
+void eos_run(void) {
int rv;
- rv = eos_net_run(wakeup_cause);
- if (rv) printf("NET RUN ERR:%d\n", rv);
+ rv = eos_eve_run();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "EVE RUN ERR:%d\n", rv);
+
+ rv = eos_egpio_run();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "EGPIO RUN ERR:%d\n", rv);
+
+ rv = eos_net_run();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "NET RUN ERR:%d\n", rv);
}
-void eos_run_once(void) {
- eos_gt911_cfg_print();
- eos_gt911_configure();
- eos_gt911_cfg_print();
+#include "dev/drv/gt911.h"
+#include "eve/eve.h"
- eos_eve_calibrate();
+void eos_run_once(void) {
+ gt911_cfg_print();
+ gt911_configure();
+ gt911_cfg_print();
+
+ eve_select();
+ eve_brightness(0x40);
+ eve_calibrate();
+ eve_brightness(0);
+ eve_deselect();
}