From 36d9e98fc6b5fb0315ade399fbd8f357a44196a6 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Thu, 30 Nov 2023 21:27:23 +0100 Subject: [PATCH] samd: Remove the MICROPY_PY_MACHINE_RTC config option. RTC is enabled on all boards. Therefore the conditional compile is not needed. Removing it simplifies the source code a little bit. Signed-off-by: robert-hh --- ports/samd/fatfs_port.c | 8 -------- ports/samd/machine_rtc.c | 4 ---- ports/samd/modmachine.c | 8 +------- ports/samd/mpconfigport.h | 1 - ports/samd/samd_soc.c | 4 ---- 5 files changed, 1 insertion(+), 24 deletions(-) diff --git a/ports/samd/fatfs_port.c b/ports/samd/fatfs_port.c index a3e3f1b67b..91912d97d8 100644 --- a/ports/samd/fatfs_port.c +++ b/ports/samd/fatfs_port.c @@ -33,13 +33,5 @@ extern uint32_t time_offset; MP_WEAK DWORD get_fattime(void) { - #if MICROPY_PY_MACHINE_RTC return (RTC->MODE2.CLOCK.reg >> 1) + (20 << 25); - #else - extern void rtc_gettime(timeutils_struct_time_t *tm); - timeutils_struct_time_t tm; - timeutils_seconds_since_epoch_to_struct_time(mp_hal_ticks_ms_64() / 1000 + time_offset, &tm); - return ((tm.tm_year - 1980) << 25) | ((tm.tm_mon) << 21) | ((tm.tm_mday) << 16) | - ((tm.tm_hour) << 11) | ((tm.tm_min) << 5) | (tm.tm_sec / 2); - #endif } diff --git a/ports/samd/machine_rtc.c b/ports/samd/machine_rtc.c index e6237f3f36..1f0c9f4dca 100644 --- a/ports/samd/machine_rtc.c +++ b/ports/samd/machine_rtc.c @@ -31,8 +31,6 @@ #include "extmod/modmachine.h" #include "sam.h" -#if MICROPY_PY_MACHINE_RTC - typedef struct _machine_rtc_obj_t { mp_obj_base_t base; mp_obj_t callback; @@ -177,5 +175,3 @@ MP_DEFINE_CONST_OBJ_TYPE( make_new, machine_rtc_make_new, locals_dict, &machine_rtc_locals_dict ); - -#endif // MICROPY_PY_MACHINE_RTC diff --git a/ports/samd/modmachine.c b/ports/samd/modmachine.c index 9aab705bf7..c39aec95ea 100644 --- a/ports/samd/modmachine.c +++ b/ports/samd/modmachine.c @@ -48,16 +48,10 @@ #define LIGHTSLEEP_CPU_FREQ 200000 -#if MICROPY_PY_MACHINE_RTC -#define MICROPY_PY_MACHINE_RTC_ENTRY { MP_ROM_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&machine_rtc_type) }, -#else -#define MICROPY_PY_MACHINE_RTC_ENTRY -#endif - #define MICROPY_PY_MACHINE_EXTRA_GLOBALS \ { MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&machine_pin_type) }, \ { MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&machine_timer_type) }, \ - MICROPY_PY_MACHINE_RTC_ENTRY \ + { MP_ROM_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&machine_rtc_type) }, \ \ /* Class constants. */ \ /* Use numerical constants instead of the symbolic names, */ \ diff --git a/ports/samd/mpconfigport.h b/ports/samd/mpconfigport.h index 21c29be24e..466a4d7751 100644 --- a/ports/samd/mpconfigport.h +++ b/ports/samd/mpconfigport.h @@ -109,7 +109,6 @@ #define MICROPY_PY_RANDOM (1) #define MICROPY_PY_DEFLATE (1) #define MICROPY_PY_ASYNCIO (1) -#define MICROPY_PY_MACHINE_RTC (1) #ifndef MICROPY_PY_MACHINE_ADC #define MICROPY_PY_MACHINE_ADC (1) #endif diff --git a/ports/samd/samd_soc.c b/ports/samd/samd_soc.c index dcfff9dc22..259640e93d 100644 --- a/ports/samd/samd_soc.c +++ b/ports/samd/samd_soc.c @@ -38,9 +38,7 @@ #include "tusb.h" #include "mphalport.h" -#if MICROPY_PY_MACHINE_RTC extern void machine_rtc_start(bool force); -#endif static void usb_init(void) { // Init USB clock @@ -124,9 +122,7 @@ void samd_init(void) { #if defined(MCU_SAMD51) mp_hal_ticks_cpu_enable(); #endif - #if MICROPY_PY_MACHINE_RTC machine_rtc_start(false); - #endif } #if MICROPY_PY_MACHINE_I2C || MICROPY_PY_MACHINE_SPI || MICROPY_PY_MACHINE_UART