• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef _PWRKEY_API_H_
16 #define _PWRKEY_API_H_
17 
18 #include "chip.h"
19 #include "plf.h"
20 #include "pmic_api.h"
21 
22 #define USER_DEFINED_PWRKEY_EN          (1)
23 #define USER_DEFINED_POWERON_TIME_MS    (0)
24 #define USER_DEFINED_POWEROFF_TIME_MS   (5200)
25 
26 enum {
27     PWRKEY_IRQ_EVENT_KEYDOWN = 0,
28     PWRKEY_IRQ_EVENT_KEYUP,
29     PWRKEY_IRQ_EVENT_KEYUP_SINGLE,
30 };
31 
32 typedef void (*pwrkey_irq_handler_t)(int event);
33 
34 /**
35  * @brief: Enable pwrkey function if necessary
36  */
37 void pwrkey_init(void);
38 
39 /**
40  * @brief: Power-on check, boot to app if got key event as user defined time
41  */
42 void pwrkey_poweron_check(void);
43 
44 /**
45  * @brief: IRQ handler with event
46  * @param[in] event: pos or neg
47  */
48 void pwrkey_irq_handler(int event);
49 
50 /**
51  * @brief: Register pwerkey IRQ callback function
52  * @param[in] event: pos or neg
53  */
54 void pwrkey_irq_callback_register(pwrkey_irq_handler_t callback);
55 
56 /**
57  * @brief: Get user config
58  * @return: Pwrkey enable or not
59  */
60 int user_pwrkey_enabled(void);
61 
62 /**
63  * @brief: Get user defined power-on time
64  * @return: Power-on time in ms, 0 or greater than 400
65  */
66 unsigned int user_pwrkey_poweron_time_get(void);
67 
68 /**
69  * @brief: Get user defined power-off time
70  * @return: Power-on time in ms
71  */
72 unsigned int user_pwrkey_poweroff_time_get(void);
73 
74 #endif /* _PWRKEY_API_H_ */
75