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