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
|
#include <stdint.h>
#define EGPIO_ETYPE_INT 1
#define EGPIO_ETYPE_INT_CTP 2
#define EGPIO_ETYPE_INT_EVE 3
#define EGPIO_INT_TYPE_BAT 1
#define EGPIO_INT_TYPE_WAKE 2
#define EGPIO_INT_TYPE_SDCARD 3
#define EGPIO_INT_TYPE_MUTE 4
#define EGPIO_INT_TYPE_HP 5
#define EGPIO_CHIP_FXL0 0x00
#define EGPIO_CHIP_FXL1 0x01
#define EGPIO_CHIP_EVE 0x02
#define EGPIO_MAX_CHIP 3
#define EGPIO_PIN_MASK 0x07
#define EGPIO_PIN_MASK_CHIP 0x30
#define EGPIO_PIN2BIT(X) (1 << ((X) & EGPIO_PIN_MASK))
#define EGPIO_PIN2CHIP(X) (((X) & EGPIO_PIN_MASK_CHIP) >> 4)
#define EGPIO_PIN(C,P) (((C) << 4) | (P))
#define EGPIO0_PIN_EVE_INT 0x00 /* EVE interrrupt */
#define EGPIO0_PIN_SDCARD_DET 0x01 /* SD Card detect */
#define EGPIO0_PIN_EXP_IO0 0x02 /* expansion io 0 */
#define EGPIO0_PIN_EXP_IO1 0x03 /* expansion io 1 */
#define EGPIO0_PIN_BTN_WAKE 0x04 /* wake button */
#define EGPIO0_PIN_BAT_INT 0x05 /* battery charger IC inetrrupt */
#define EGPIO0_PIN_CTP_SEL 0x06 /* switch CTP connection: EVE_DISP:1 and CTP_SEL:0 - connected to EVE chip, EVE_DISP:X and CTP_SEL:1 - connected to fe310 chip, EVE_DISP:0 and CTP_SEL:0 - connected to app module */
#define EGPIO0_PIN_CTP_INT 0x07 /* CTP interrupt */
#define EGPIO1_PIN_MIC_MUTE 0x00 /* microphone disable */
#define EGPIO1_PIN_HPAMP_CS 0x01 /* SPI chip select for headphone amplifier (pcm1770) */
#define EGPIO1_PIN_AUDIO_SEL 0x02 /* switch audio connection: 0 - connected to app module, 1 - connected to fe310 chip (only when i2s is off) */
#define EGPIO1_PIN_HP_NDET 0x03 /* headphone detect: 0 - inserted, 1 - not inserted */
#define EGPIO1_PIN_USR0 0x04 /* user IO */
#define EGPIO1_PIN_USR1 0x05
#define EGPIO1_PIN_USR2 0x06
#define EGPIO1_PIN_USR3 0x07
#define EGPIOE_PIN_DISP 0x07 /* EVE DISP GPIO */
#define EGPIO_PIN_ALT 0x08
#define EGPIO_PIN_EVE_INT EGPIO_PIN(EGPIO_CHIP_FXL0, EGPIO0_PIN_EVE_INT)
#define EGPIO_PIN_SDCARD_DET EGPIO_PIN(EGPIO_CHIP_FXL0, EGPIO0_PIN_SDCARD_DET)
#define EGPIO_PIN_EXP_IO0 EGPIO_PIN(EGPIO_CHIP_FXL0, EGPIO0_PIN_EXP_IO0)
#define EGPIO_PIN_EXP_IO1 EGPIO_PIN(EGPIO_CHIP_FXL0, EGPIO0_PIN_EXP_IO1)
#define EGPIO_PIN_BTN_WAKE EGPIO_PIN(EGPIO_CHIP_FXL0, EGPIO0_PIN_BTN_WAKE)
#define EGPIO_PIN_BAT_INT EGPIO_PIN(EGPIO_CHIP_FXL0, EGPIO0_PIN_BAT_INT)
#define EGPIO_PIN_CTP_SEL EGPIO_PIN(EGPIO_CHIP_FXL0, EGPIO0_PIN_CTP_SEL)
#define EGPIO_PIN_CTP_INT EGPIO_PIN(EGPIO_CHIP_FXL0, EGPIO0_PIN_CTP_INT)
#define EGPIO_PIN_MIC_MUTE EGPIO_PIN(EGPIO_CHIP_FXL1, EGPIO1_PIN_MIC_MUTE)
#define EGPIO_PIN_HPAMP_CS EGPIO_PIN(EGPIO_CHIP_FXL1, EGPIO1_PIN_HPAMP_CS)
#define EGPIO_PIN_AUDIO_SEL EGPIO_PIN(EGPIO_CHIP_FXL1, EGPIO1_PIN_AUDIO_SEL)
#define EGPIO_PIN_HP_NDET EGPIO_PIN(EGPIO_CHIP_FXL1, EGPIO1_PIN_HP_NDET)
#define EGPIO_PIN_USR0 EGPIO_PIN(EGPIO_CHIP_FXL1, EGPIO1_PIN_USR0)
#define EGPIO_PIN_USR1 EGPIO_PIN(EGPIO_CHIP_FXL1, EGPIO1_PIN_USR1)
#define EGPIO_PIN_USR2 EGPIO_PIN(EGPIO_CHIP_FXL1, EGPIO1_PIN_USR2)
#define EGPIO_PIN_USR3 EGPIO_PIN(EGPIO_CHIP_FXL1, EGPIO1_PIN_USR3)
/* EVE pins defined in eve.h */
#define EGPIO_PIN_USR4 EGPIO_PIN(EGPIO_CHIP_EVE, EVE_GPIO_USR)
#define EGPIO_PIN_EVEAUDIO_DIS EGPIO_PIN(EGPIO_CHIP_EVE, EVE_GPIO_EVEAUDIO_DIS)
#define EGPIO_PIN_LSGAIN_SEL EGPIO_PIN(EGPIO_CHIP_EVE, EVE_GPIO_LSGAIN_SEL | EGPIO_PIN_ALT)
#define EGPIO_PIN_LCD_EN EGPIO_PIN(EGPIO_CHIP_EVE, EVE_GPIO_LCD_EN)
#define EGPIO_PIN_CAM_EN EGPIO_PIN(EGPIO_CHIP_EVE, EVE_GPIO_CAM_EN)
#define EGPIO_PIN_DISP_SEL EGPIO_PIN(EGPIO_CHIP_EVE, EGPIOE_PIN_DISP)
#define EGPIO_BIT_EVE_INT EGPIO_PIN2BIT(EGPIO0_PIN_EVE_INT)
#define EGPIO_BIT_SDCARD_DET EGPIO_PIN2BIT(EGPIO0_PIN_SDCARD_DET)
#define EGPIO_BIT_EXP_IO0 EGPIO_PIN2BIT(EGPIO0_PIN_EXP_IO0)
#define EGPIO_BIT_EXP_IO1 EGPIO_PIN2BIT(EGPIO0_PIN_EXP_IO1)
#define EGPIO_BIT_BTN_WAKE EGPIO_PIN2BIT(EGPIO0_PIN_BTN_WAKE)
#define EGPIO_BIT_BAT_INT EGPIO_PIN2BIT(EGPIO0_PIN_BAT_INT)
#define EGPIO_BIT_CTP_SEL EGPIO_PIN2BIT(EGPIO0_PIN_CTP_SEL)
#define EGPIO_BIT_CTP_INT EGPIO_PIN2BIT(EGPIO0_PIN_CTP_INT)
#define EGPIO_BIT_MIC_MUTE EGPIO_PIN2BIT(EGPIO1_PIN_MIC_MUTE)
#define EGPIO_BIT_HPAMP_CS EGPIO_PIN2BIT(EGPIO1_PIN_HPAMP_CS)
#define EGPIO_BIT_AUDIO_SEL EGPIO_PIN2BIT(EGPIO1_PIN_AUDIO_SEL)
#define EGPIO_BIT_HP_NDET EGPIO_PIN2BIT(EGPIO1_PIN_HP_NDET)
#define EGPIO_BIT_USR0 EGPIO_PIN2BIT(EGPIO1_PIN_USR0)
#define EGPIO_BIT_USR1 EGPIO_PIN2BIT(EGPIO1_PIN_USR1)
#define EGPIO_BIT_USR2 EGPIO_PIN2BIT(EGPIO1_PIN_USR2)
#define EGPIO_BIT_USR3 EGPIO_PIN2BIT(EGPIO1_PIN_USR3)
typedef void (*eos_egpio_intr_handler_t) (uint8_t type, int data0, int data1);
typedef int (*eos_egpio_ext_handler_t) (void);
int eos_egpio_init(void);
int eos_egpio_run(void);
void eos_egpio_eve_set(uint16_t gpio_reg);
int _eos_egpio_intr_set(int i2s_running, int app_running);
int eos_egpio_intr_set(void);
int eos_egpio_intr_enable(void);
int eos_egpio_intr_disable(void);
void eos_egpio_set_intr_handler(eos_egpio_intr_handler_t handler);
void eos_egpio_set_ext_handler(eos_egpio_ext_handler_t handler);
int eos_egpio_fxl_get_pin(uint8_t reg, uint8_t pin, uint8_t *val);
int eos_egpio_fxl_set_pin(uint8_t reg, uint8_t pin, uint8_t val);
int _eos_egpio_get_val(uint8_t pin);
int _eos_egpio_set_val(uint8_t pin, int val);
int eos_egpio_get_val(uint8_t pin);
int eos_egpio_set_val(uint8_t pin, int val);
int eos_egpio_i2s_start(void);
int eos_egpio_i2s_stop(void);
|