File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,19 @@ STATIC mp_obj_t machine_rtc_init(mp_obj_t self_in, mp_obj_t date) {
142
142
STATIC MP_DEFINE_CONST_FUN_OBJ_2 (machine_rtc_init_obj , machine_rtc_init );
143
143
144
144
#if MICROPY_HW_RTC_USER_MEM_MAX > 0
145
+ /*
146
+ * both RTC().usermem() and RTC().memory() refer to the same area in memory.
147
+ * RTC().memory() is here for backward compatibility.
148
+ */
149
+
150
+ // returns a bytearray referencing the whole user memory.
151
+ STATIC mp_obj_t machine_rtc_usermem (mp_obj_t self_in ) {
152
+ // mp_obj_t *self = MP_OBJ_TO_PTR(self_in);
153
+ return mp_obj_new_bytearray_by_ref (MICROPY_HW_RTC_USER_MEM_MAX , (void * )rtc_user_mem_data );
154
+ }
155
+ MP_DEFINE_CONST_FUN_OBJ_1 (machine_rtc_usermem_obj , machine_rtc_usermem );
156
+
157
+
145
158
STATIC mp_obj_t machine_rtc_memory (mp_uint_t n_args , const mp_obj_t * args ) {
146
159
if (n_args == 1 ) {
147
160
// read RTC memory
@@ -169,6 +182,7 @@ STATIC const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
169
182
{ MP_ROM_QSTR (MP_QSTR_datetime ), MP_ROM_PTR (& machine_rtc_datetime_obj ) },
170
183
#if MICROPY_HW_RTC_USER_MEM_MAX > 0
171
184
{ MP_ROM_QSTR (MP_QSTR_memory ), MP_ROM_PTR (& machine_rtc_memory_obj ) },
185
+ { MP_ROM_QSTR (MP_QSTR_usermem ), MP_ROM_PTR (& machine_rtc_usermem_obj ) },
172
186
#endif
173
187
};
174
188
STATIC MP_DEFINE_CONST_DICT (machine_rtc_locals_dict , machine_rtc_locals_dict_table );
You can’t perform that action at this time.
0 commit comments