1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4
5 #include "py/mperrno.h"
6 #include "py/obj.h"
7 #include "py/runtime.h"
8 #include "py/builtin.h"
9
10 #include "ulog/ulog.h"
11
12 #define LOG_TAG "MOD_PM"
13
obj_open(size_t n_args,const mp_obj_t * args)14 STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args)
15 {
16 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
17 int ret = -1;
18 void* instance = NULL;
19 if (n_args < 5)
20 {
21 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
22 return mp_const_none;
23 }
24 LOGD(LOG_TAG, "%s:out\n", __func__);
25
26 return mp_const_none;
27 }
28 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_open, 5, obj_open);
29
obj_close(size_t n_args,const mp_obj_t * args)30 STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args)
31 {
32 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
33 int ret = -1;
34 void* instance = NULL;
35 if (n_args < 5)
36 {
37 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
38 return mp_const_none;
39 }
40 LOGD(LOG_TAG, "%s:out\n", __func__);
41
42 return mp_const_none;
43 }
44 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_close, 5, obj_close);
45
obj_setAutosleepMode(size_t n_args,const mp_obj_t * args)46 STATIC mp_obj_t obj_setAutosleepMode(size_t n_args, const mp_obj_t *args)
47 {
48 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
49 int ret = -1;
50 void* instance = NULL;
51 if (n_args < 5)
52 {
53 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
54 return mp_const_none;
55 }
56 LOGD(LOG_TAG, "%s:out\n", __func__);
57
58 return mp_const_none;
59 }
60 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_setAutosleepMode, 5, obj_setAutosleepMode);
61
obj_getAutosleepMode(size_t n_args,const mp_obj_t * args)62 STATIC mp_obj_t obj_getAutosleepMode(size_t n_args, const mp_obj_t *args)
63 {
64 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
65 int ret = -1;
66 void* instance = NULL;
67 if (n_args < 5)
68 {
69 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
70 return mp_const_none;
71 }
72 LOGD(LOG_TAG, "%s:out\n", __func__);
73
74 return mp_const_none;
75 }
76 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_getAutosleepMode, 5, obj_getAutosleepMode);
77
obj_sleep(size_t n_args,const mp_obj_t * args)78 STATIC mp_obj_t obj_sleep(size_t n_args, const mp_obj_t *args)
79 {
80 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
81 int ret = -1;
82 void* instance = NULL;
83 if (n_args < 5)
84 {
85 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
86 return mp_const_none;
87 }
88 LOGD(LOG_TAG, "%s:out\n", __func__);
89
90 return mp_const_none;
91 }
92 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_sleep, 5, obj_sleep);
93
obj_powerDown(size_t n_args,const mp_obj_t * args)94 STATIC mp_obj_t obj_powerDown(size_t n_args, const mp_obj_t *args)
95 {
96 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
97 int ret = -1;
98 void* instance = NULL;
99 if (n_args < 5)
100 {
101 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
102 return mp_const_none;
103 }
104 LOGD(LOG_TAG, "%s:out\n", __func__);
105
106 return mp_const_none;
107 }
108 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_powerDown, 5, obj_powerDown);
109
obj_powerReset(size_t n_args,const mp_obj_t * args)110 STATIC mp_obj_t obj_powerReset(size_t n_args, const mp_obj_t *args)
111 {
112 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
113 int ret = -1;
114 void* instance = NULL;
115 if (n_args < 5)
116 {
117 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
118 return mp_const_none;
119 }
120 LOGD(LOG_TAG, "%s:out\n", __func__);
121
122 return mp_const_none;
123 }
124 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_powerReset, 5, obj_powerReset);
125
obj_wakelockLock(size_t n_args,const mp_obj_t * args)126 STATIC mp_obj_t obj_wakelockLock(size_t n_args, const mp_obj_t *args)
127 {
128 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
129 int ret = -1;
130 void* instance = NULL;
131 if (n_args < 5)
132 {
133 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
134 return mp_const_none;
135 }
136 LOGD(LOG_TAG, "%s:out\n", __func__);
137
138 return mp_const_none;
139 }
140 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_wakelockLock, 5, obj_wakelockLock);
141
obj_wakelockUnlock(size_t n_args,const mp_obj_t * args)142 STATIC mp_obj_t obj_wakelockUnlock(size_t n_args, const mp_obj_t *args)
143 {
144 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
145 int ret = -1;
146 void* instance = NULL;
147 if (n_args < 5)
148 {
149 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
150 return mp_const_none;
151 }
152 LOGD(LOG_TAG, "%s:out\n", __func__);
153
154 return mp_const_none;
155 }
156 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_wakelockUnlock, 5, obj_wakelockUnlock);
157
obj_wakelockTimedlock(size_t n_args,const mp_obj_t * args)158 STATIC mp_obj_t obj_wakelockTimedlock(size_t n_args, const mp_obj_t *args)
159 {
160 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
161 int ret = -1;
162 void* instance = NULL;
163 if (n_args < 5)
164 {
165 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
166 return mp_const_none;
167 }
168 LOGD(LOG_TAG, "%s:out\n", __func__);
169
170 return mp_const_none;
171 }
172 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_wakelockTimedlock, 5, obj_wakelockTimedlock);
173
obj_onPwrkey(size_t n_args,const mp_obj_t * args)174 STATIC mp_obj_t obj_onPwrkey(size_t n_args, const mp_obj_t *args)
175 {
176 LOGD(LOG_TAG, "entern %s; n_args = %d;\n", __func__, n_args);
177 int ret = -1;
178 void* instance = NULL;
179 if (n_args < 5)
180 {
181 LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
182 return mp_const_none;
183 }
184 LOGD(LOG_TAG, "%s:out\n", __func__);
185
186 return mp_const_none;
187 }
188 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(pm_obj_onPwrkey, 5, obj_onPwrkey);
189
190 STATIC const mp_rom_map_elem_t pm_locals_dict_table[] = {
191 {MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_PM)},
192 {MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&pm_obj_open)},
193 {MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&pm_obj_close)},
194 {MP_ROM_QSTR(MP_QSTR_setAutosleepMode), MP_ROM_PTR(&pm_obj_setAutosleepMode)},
195 {MP_ROM_QSTR(MP_QSTR_getAutosleepMode), MP_ROM_PTR(&pm_obj_getAutosleepMode)},
196 {MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&pm_obj_sleep)},
197 {MP_ROM_QSTR(MP_QSTR_powerDown), MP_ROM_PTR(&pm_obj_powerDown)},
198 {MP_ROM_QSTR(MP_QSTR_powerReset), MP_ROM_PTR(&pm_obj_powerReset)},
199 {MP_ROM_QSTR(MP_QSTR_wakelockLock), MP_ROM_PTR(&pm_obj_wakelockLock)},
200 {MP_ROM_QSTR(MP_QSTR_wakelockUnlock), MP_ROM_PTR(&pm_obj_wakelockUnlock)},
201 {MP_ROM_QSTR(MP_QSTR_wakelockTimedlock), MP_ROM_PTR(&pm_obj_wakelockTimedlock)},
202 {MP_ROM_QSTR(MP_QSTR_onPwrkey), MP_ROM_PTR(&pm_obj_onPwrkey)},
203 };
204
205 STATIC MP_DEFINE_CONST_DICT(pm_locals_dict, pm_locals_dict_table);
206
207 const mp_obj_module_t pm_module = {
208 .base = {&mp_type_module},
209 .globals = (mp_obj_dict_t *)&pm_locals_dict,
210 };
211