From 1530fda9cf27d793917ea00ad28fbe8d4955b232 Mon Sep 17 00:00:00 2001 From: Josh Lloyd Date: Thu, 21 Nov 2019 15:09:01 +1300 Subject: [PATCH] esp32/machine_rtc: Reduce memory footprint of user mem functionality. --- ports/esp32/machine_rtc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ports/esp32/machine_rtc.c b/ports/esp32/machine_rtc.c index b0268cd57f..eaa70e2448 100644 --- a/ports/esp32/machine_rtc.c +++ b/ports/esp32/machine_rtc.c @@ -64,7 +64,7 @@ typedef struct _machine_rtc_obj_t { #if MICROPY_HW_RTC_USER_MEM_MAX > 0 #define MEM_MAGIC 0x75507921 RTC_DATA_ATTR uint32_t rtc_user_mem_magic; -RTC_DATA_ATTR uint32_t rtc_user_mem_len; +RTC_DATA_ATTR uint16_t rtc_user_mem_len; RTC_DATA_ATTR uint8_t rtc_user_mem_data[MICROPY_HW_RTC_USER_MEM_MAX]; #endif @@ -145,10 +145,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(machine_rtc_init_obj, machine_rtc_init); STATIC mp_obj_t machine_rtc_memory(mp_uint_t n_args, const mp_obj_t *args) { if (n_args == 1) { // read RTC memory - uint32_t len = rtc_user_mem_len; uint8_t rtcram[MICROPY_HW_RTC_USER_MEM_MAX]; - memcpy( (char *) rtcram, (char *) rtc_user_mem_data, len); - return mp_obj_new_bytes(rtcram, len); + memcpy((char*)rtcram, (char*)rtc_user_mem_data, rtc_user_mem_len); + return mp_obj_new_bytes(rtcram, rtc_user_mem_len); } else { // write RTC memory mp_buffer_info_t bufinfo;