1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#include <stdio.h>
#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"
#include "soc/uart.h"
#include "soc/spi.h"
#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/batt.h"
#include "dev/eve.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;
int rv;
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_LOG(EOS_LOG_INFO, "INIT:%d\n", wakeup_cause);
EOS_LOG(EOS_LOG_INFO, "FREQ:%lu\n", PRCI_get_cpu_freq());
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_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_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_egpio_init();
if (rv) EOS_LOG(EOS_LOG_ERR, "EGPIO INIT ERR:%d\n", rv);
rv = eos_batt_init();
if (rv) EOS_LOG(EOS_LOG_ERR, "BATT 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_eve_init();
if (rv) EOS_LOG(EOS_LOG_ERR, "EVE INIT 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_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(void) {
int 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);
}
#include "dev/drv/gt911.h"
#include "eve/eve.h"
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();
}
|