key_scan.h
4.06 KB
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
#ifndef _KEY_SCAN_H_
#define _KEY_SCAN_H_
#include "app_i2c.h"
#define TOP_OPEN 1
#define TOP_CLOSE 0
#define HOLD_ON 1
#define HOLD_OFF 0
enum {
KEY_DOWN,
KEY_UP,
KEY_HOLD
};
#if(defined OTK5283P || defined OTK5282P)
//*** *********************************************************
//* ----------------------------------------------------------
//* Batter Voltage Range | Corresponding ADC Voltage Value |
//* 4.2V | 0xE8B |
//* 4.1V | 0xE31 |
//* 4.0V | 0xDDA |
//* 3.9V | 0xD82 |
//* 3.8V | 0xD2B |
//* 3.7V | 0xCD3 |
//* 3.6V | 0xC78 |
//* 3.5V | 0xC1F |
//* 3.4V | 0xBC3 |
//* 3.3V | 0xB6F |
//* 3.2V | 0xB11 |
//* 3.1V | 0xABD |
//* 3.0V | 0xA60 |
//* 2.9V | 0xA05
//* 2.85V | 0x9D9 |
//* ----------------------------------------------------------
//* below "P" means Percent(%)
//* It needs constant current of using 0.2c-0.3c or 1c to charge during 3.2-4.2v.
//* Standard charging mothed: 0.2C constant current, 4.2V constant voltage charge to 4.2,continue
//* charging nutill current decline to less than 0.01C.
#define BATT_VOL_TRICKLE 0xA60 // it needs to tickle charge while battery level is less than 3.0v
#define BATT_VOL_LOW 0xC1F // @3.5v 0.2C dischanging curve
#define BATT_VOL_20P 0xC78 // @3.6v 0.2C dischanging curve
#define BATT_VOL_MID 0xD2B // @3.7v 0.2C dischanging curve
#define BATT_VOL_70P 0xD2B // @3.8v 0.2C dischanging curve
#define BATT_VOL_80P 0xD82 // @3.9v 0.2C dischanging curve
#define BATT_VOL_90P 0xDDA // @4.0v 0.2C dischanging curve
#define BATT_VOL_FULL 0xE8B // @4.2v-4.0v
#define BATT_VOL_PWE_OFF 0xC00
enum {
enBATT_VOL_00P,
enBATT_VOL_10P,
enBATT_VOL_20P,
enBATT_VOL_50P =5,
enBATT_VOL_70P =7,
enBATT_VOL_80P,
enBATT_VOL_90P,
enBATT_VOL_100P,
};
#define ADAPTER_DET_PIN GPIO2_11_INDEX
#if 1
#define ADAPTER_DET_PIN_INPUT_SET GPIO_MUXFUNCTION_SELECT(ADAPTER_DET_PIN, MUX_SEL_GPIO_INPUT)
#else
#define PIN_HIGH_TEST GPIO_MUXFUNCTION_SELECT(ADAPTER_DET_PIN, MUX_SEL_GPIO_OUTPUT);\
GPIO_OUTPUT_LEVEL_SET (ADAPTER_DET_PIN, GPIO_HIGH)
#define PIN_LOW_TEST GPIO_MUXFUNCTION_SELECT(ADAPTER_DET_PIN, MUX_SEL_GPIO_OUTPUT);\
GPIO_OUTPUT_LEVEL_SET (ADAPTER_DET_PIN, GPIO_LOW)
#endif
#endif
extern U8 top_status;
void KeyScan_init(void);
void KeyScan_open (void);
void KeyScan_close (void);
void KeyScan_fini (void);
void vAdTask(void);
void KeyScan_repeat_enable (void);
void KeyScan(U32 ticks);
U8 hold_key_detect (void);
U8 top_key_detect(void);
U8 cd_open_close_key_detect(void);
U8 PLAY_key_detect(void);
U8 resume_key_detect(void);
void vAd0MapMainKey (U16 *key_ad);
void vAd1MapMainKey (U16 *key_ad);
void vAd2MapMainKey (U16 *key_ad);
void vRemoteMapMainKey(U32 *key_ad);
void vRemoteCDMapMainKey(U16 *key_ad);
void vRemoteUSBMapMainKey(U16 *key_ad);
U8 rotary_KeyScan(void);
U8 USB_Detect(void);
U8 PowerOff_Detect(void);
void cd_input_timer_handler(void);
void power_protect_polling(void);
void amp_protect_polling(void);
void bt_auto_connected_polling(void);
void bt_auto_disconnected_polling(void);
void headphone_detect_polling(void);
void mic_external_detect_polling(void);
void battery_energy_indicator(U16 average);
static void print_no_battery_or_is_bad (void);
extern volatile U8 NTCdetect;
#endif //_KEY_SCAN_H_