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
|
#include <stdio.h>
#include "event.h"
#include "interrupt.h"
#include "timer.h"
#include "power.h"
#include "i2s.h"
#include "i2c.h"
#include "uart.h"
#include "spi.h"
#include "spi_dev.h"
#include "lcd.h"
#include "sdcard.h"
#include "net.h"
#include "wifi.h"
#include "cell.h"
#include "sock.h"
#include "i2c/bq25895.h"
#include "eve/eve.h"
#include "board.h"
#include "eos.h"
void eos_init(void) {
uint8_t wakeup_cause = eos_power_wakeup_cause() | EOS_PWR_INIT;
uint32_t touch_matrix[6] = {0xfa46,0xfffffcf6,0x422fe,0xffffff38,0x10002,0xf3cb0};
int touch_calibrate = 0;
int rv;
printf("INIT:%d\n", wakeup_cause & ~EOS_PWR_INIT);
rv = eos_evtq_init(wakeup_cause);
if (rv) printf("EVTQ INIT ERR:%d\n", rv);
rv = eos_intr_init(wakeup_cause);
if (rv) printf("INTR INIT ERR:%d\n", rv);
rv = eos_timer_init(wakeup_cause);
if (rv) printf("TIMER 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_uart_init(wakeup_cause);
if (rv) printf("UART 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_sdc_init(wakeup_cause);
if (rv) printf("SDC INIT ERR:%d\n", rv);
rv = eos_net_init(wakeup_cause);
if (rv) printf("NET INIT ERR:%d\n", rv);
rv = eos_power_init(wakeup_cause);
if (rv) printf("POWER INIT ERR:%d\n", rv);
rv = eos_bq25895_init(wakeup_cause);
if (rv) printf("BQ25895 INIT ERR:%d\n", rv);
eos_spi_select(EOS_SPI_DEV_EVE);
rv = eve_init(wakeup_cause, touch_calibrate, touch_matrix, EVE_GPIO_DIR);
eos_spi_deselect();
if (rv) printf("EVE INIT ERR:%d\n", rv);
rv = eos_lcd_init(wakeup_cause);
if (rv) printf("LCD INIT ERR:%d\n", rv);
if (touch_calibrate) {
printf("TOUCH MATRIX:\n");
printf("uint32_t touch_matrix[6] = {0x%x,0x%x,0x%x,0x%x,0x%x,0x%x}\n", touch_matrix[0], touch_matrix[1], touch_matrix[2], touch_matrix[3], touch_matrix[4], touch_matrix[5]);
}
eos_start(wakeup_cause);
}
void eos_start(uint8_t wakeup_cause) {
eos_spi_select(EOS_SPI_DEV_EVE);
eve_start(wakeup_cause);
eos_spi_deselect();
eos_wifi_init();
eos_cell_init();
eos_sock_init();
eos_net_start(wakeup_cause);
}
|