File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,20 @@ STATIC mp_obj_t time_time(void) {
206
206
}
207
207
MP_DEFINE_CONST_FUN_OBJ_0 (time_time_obj , time_time );
208
208
209
+ //| .. method:: monotonic_ns(clk_id)
210
+ //|
211
+ //| Return the time of the specified clock clk_id in nanoseconds. Refer to
212
+ //| Clock ID Constants for a list of accepted values for clk_id.
213
+ //|
214
+ //| :return: the current time
215
+ //| :rtype: int
216
+ //|
217
+ STATIC mp_obj_t time_monotonic_ns (void ) {
218
+ uint64_t time64 = common_hal_time_monotonic () * 1000000llu ;
219
+ return mp_obj_new_int_from_ll ((long long ) time64 );
220
+ }
221
+ MP_DEFINE_CONST_FUN_OBJ_0 (time_monotonic_ns_obj , time_monotonic_ns );
222
+
209
223
//| .. method:: localtime([secs])
210
224
//|
211
225
//| Convert a time expressed in seconds since Jan 1, 1970 to a struct_time in
@@ -280,6 +294,7 @@ STATIC const mp_rom_map_elem_t time_module_globals_table[] = {
280
294
#endif // MICROPY_PY_COLLECTIONS
281
295
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
282
296
{ MP_ROM_QSTR (MP_QSTR_time ), MP_ROM_PTR (& time_time_obj ) },
297
+ { MP_ROM_QSTR (MP_QSTR_monotonic_ns ), MP_ROM_PTR (& time_monotonic_ns_obj ) },
283
298
#endif
284
299
};
285
300
You can’t perform that action at this time.
0 commit comments