From 8d1719f190f249ebb0e53c4f42a81d7fc16f4e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Sat, 7 Apr 2018 15:00:13 +0200 Subject: [PATCH 1/4] Add rtc module Add an rtc module that provides a singleton RTC class with - a datetime property to set and get time if the board supports it. - a calbration property to adjust the clock. There's also an rtc.set_time_source() method to override this RTC object using pure python. The time module gets 3 methods: - time.time() - time.localtime() - time.mktime() The rtc timesource is used to provide time to the time module. lib/timeutils is used for time conversions and thus only supports dates after 2000. --- shared-bindings/rtc/RTC.c | 135 ++++++++++++++++++++++++++++++++ shared-bindings/rtc/RTC.h | 49 ++++++++++++ shared-bindings/rtc/__init__.c | 93 ++++++++++++++++++++++ shared-bindings/rtc/__init__.h | 33 ++++++++ shared-bindings/time/__init__.c | 121 ++++++++++++++++++++++++++++ shared-bindings/time/__init__.h | 5 ++ 6 files changed, 436 insertions(+) create mode 100644 shared-bindings/rtc/RTC.c create mode 100644 shared-bindings/rtc/RTC.h create mode 100644 shared-bindings/rtc/__init__.c create mode 100644 shared-bindings/rtc/__init__.h diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c new file mode 100644 index 0000000000..30df20145d --- /dev/null +++ b/shared-bindings/rtc/RTC.c @@ -0,0 +1,135 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Noralf Trønnes + * Copyright (c) 2013, 2014 Damien P. George + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/obj.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "lib/timeutils/timeutils.h" +#include "shared-bindings/rtc/__init__.h" +#include "shared-bindings/rtc/RTC.h" +#include "shared-bindings/time/__init__.h" + +void MP_WEAK common_hal_rtc_get_time(timeutils_struct_time_t *tm) { + mp_raise_NotImplementedError("RTC is not supported on this board"); +} + +void MP_WEAK common_hal_rtc_set_time(timeutils_struct_time_t *tm) { + mp_raise_NotImplementedError("RTC is not supported on this board"); +} + +int MP_WEAK common_hal_rtc_get_calibration(void) { + return 0; +} + +void MP_WEAK common_hal_rtc_set_calibration(int calibration) { + mp_raise_NotImplementedError("RTC calibration is not supported on this board"); +} + +const rtc_rtc_obj_t rtc_rtc_obj = {{&rtc_rtc_type}}; + +//| .. currentmodule:: rtc +//| +//| :class:`RTC` --- Real Time Clock +//| -------------------------------- +//| +//| .. class:: RTC() +//| +//| This class represents the onboard Real Time Clock. It is a singleton and will always return the same instance. +//| +STATIC mp_obj_t rtc_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + // No arguments + mp_arg_check_num(n_args, n_kw, 0, 0, false); + + // return constant object + return (mp_obj_t)&rtc_rtc_obj; +} + +//| .. attribute:: datetime +//| +//| Get or set the date and time of the RTC. +//| +STATIC mp_obj_t rtc_rtc_obj_get_datetime(mp_obj_t self_in) { + timeutils_struct_time_t tm; + common_hal_rtc_get_time(&tm); + return struct_time_from_tm(&tm); +} +MP_DEFINE_CONST_FUN_OBJ_1(rtc_rtc_get_datetime_obj, rtc_rtc_obj_get_datetime); + +STATIC mp_obj_t rtc_rtc_obj_set_datetime(mp_obj_t self_in, mp_obj_t datetime) { + timeutils_struct_time_t tm; + struct_time_to_tm(datetime, &tm); + common_hal_rtc_set_time(&tm); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(rtc_rtc_set_datetime_obj, rtc_rtc_obj_set_datetime); + +const mp_obj_property_t rtc_rtc_datetime_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&rtc_rtc_get_datetime_obj, + (mp_obj_t)&rtc_rtc_set_datetime_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +//| .. attribute:: calibration +//| +//| The RTC calibration value. +//| A positive value speeds up the clock and a negative value slows it down. +//| Range and value is hardware specific, but one step is often approx. 1 ppm. +//| +STATIC mp_obj_t rtc_rtc_obj_get_calibration(mp_obj_t self_in) { + int calibration = common_hal_rtc_get_calibration(); + return mp_obj_new_int(calibration); +} +MP_DEFINE_CONST_FUN_OBJ_1(rtc_rtc_get_calibration_obj, rtc_rtc_obj_get_calibration); + +STATIC mp_obj_t rtc_rtc_obj_set_calibration(mp_obj_t self_in, mp_obj_t calibration) { + common_hal_rtc_set_calibration(mp_obj_get_int(calibration)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(rtc_rtc_set_calibration_obj, rtc_rtc_obj_set_calibration); + +const mp_obj_property_t rtc_rtc_calibration_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&rtc_rtc_get_calibration_obj, + (mp_obj_t)&rtc_rtc_set_calibration_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +STATIC const mp_rom_map_elem_t rtc_rtc_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_datetime), MP_ROM_PTR(&rtc_rtc_datetime_obj) }, + { MP_ROM_QSTR(MP_QSTR_calibration), MP_ROM_PTR(&rtc_rtc_calibration_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(rtc_rtc_locals_dict, rtc_rtc_locals_dict_table); + +const mp_obj_type_t rtc_rtc_type = { + { &mp_type_type }, + .name = MP_QSTR_RTC, + .make_new = rtc_rtc_make_new, + .locals_dict = (mp_obj_dict_t*)&rtc_rtc_locals_dict, +}; diff --git a/shared-bindings/rtc/RTC.h b/shared-bindings/rtc/RTC.h new file mode 100644 index 0000000000..76510bd729 --- /dev/null +++ b/shared-bindings/rtc/RTC.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Noralf Trønnes + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_RTC_RTC_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_RTC_RTC_H + +#include +#include + +#include "lib/timeutils/timeutils.h" + +extern void common_hal_rtc_get_time(timeutils_struct_time_t *tm); +extern void common_hal_rtc_set_time(timeutils_struct_time_t *tm); + +extern int common_hal_rtc_get_calibration(void); +extern void common_hal_rtc_set_calibration(int calibration); + +extern const mp_obj_type_t rtc_rtc_type; + +typedef struct _rtc_rtc_obj_t { + mp_obj_base_t base; +} rtc_rtc_obj_t; + +extern const rtc_rtc_obj_t rtc_rtc_obj; + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_RTC_RTC_H diff --git a/shared-bindings/rtc/__init__.c b/shared-bindings/rtc/__init__.c new file mode 100644 index 0000000000..89e3a24dd2 --- /dev/null +++ b/shared-bindings/rtc/__init__.c @@ -0,0 +1,93 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Noralf Trønnes + * Copyright (c) 2013, 2014 Damien P. George + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/runtime.h" +#include "shared-bindings/rtc/__init__.h" +#include "shared-bindings/rtc/RTC.h" +#include "shared-bindings/time/__init__.h" + +//| :mod:`rtc` --- Real Time Clock +//| ======================================================== +//| +//| .. module:: rtc +//| :synopsis: Real Time Clock +//| :platform: SAMD21 +//| +//| The `rtc` module provides support for a Real Time Clock. +//| It also backs the `time.time()` and `time.localtime()` functions using the onboard RTC if present. +//| + +void rtc_reset(void) { + MP_STATE_VM(rtc_time_source) = (mp_obj_t)&rtc_rtc_obj; +} + +mp_obj_t rtc_get_time_source_time(void) { + mp_obj_t datetime = mp_load_attr(MP_STATE_VM(rtc_time_source), MP_QSTR_datetime); + timeutils_struct_time_t tm; + struct_time_to_tm(datetime, &tm); + // This sets tm_wday and tm_yday + return struct_time_from_tm(&tm); +} + +//| .. function:: set_time_source(rtc) +//| +//| Sets the rtc time source used by time.localtime(). +//| The default is `rtc.RTC()`. +//| +//| Example usage:: +//| +//| import rtc +//| import time +//| +//| class RTC(object): +//| @property +//| def datetime(self): +//| return time.struct_time((2018, 3, 17, 21, 1, 47, 0, 0, 0)) +//| +//| r = RTC() +//| rtc.set_time_source(r) +//| +STATIC mp_obj_t rtc_set_time_source(mp_obj_t time_source) { + MP_STATE_VM(rtc_time_source) = time_source; + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(rtc_set_time_source_obj, rtc_set_time_source); + +STATIC const mp_rom_map_elem_t rtc_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_rtc) }, + { MP_ROM_QSTR(MP_QSTR_set_time_source), MP_ROM_PTR(&rtc_set_time_source_obj) }, + { MP_ROM_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&rtc_rtc_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(rtc_module_globals, rtc_module_globals_table); + +const mp_obj_module_t rtc_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&rtc_module_globals, +}; diff --git a/shared-bindings/rtc/__init__.h b/shared-bindings/rtc/__init__.h new file mode 100644 index 0000000000..0ee51fba5e --- /dev/null +++ b/shared-bindings/rtc/__init__.h @@ -0,0 +1,33 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Noralf Trønnes + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_RTC___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_RTC___INIT___H + +extern void rtc_reset(void); +extern mp_obj_t rtc_get_time_source_time(void); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_RTC___INIT___H diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 6956cc4e65..b4137706ee 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -30,6 +30,8 @@ #include "py/obj.h" #include "py/objnamedtuple.h" +#include "lib/timeutils/timeutils.h" +#include "shared-bindings/rtc/__init__.h" #include "shared-bindings/time/__init__.h" //| :mod:`time` --- time and timing related functions @@ -133,6 +135,122 @@ const mp_obj_namedtuple_type_t struct_time_type_obj = { MP_QSTR_tm_isdst }, }; + +mp_obj_t struct_time_from_tm(timeutils_struct_time_t *tm) { + timeutils_struct_time_t tmp; + mp_uint_t secs = timeutils_seconds_since_2000(tm->tm_year, tm->tm_mon, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); + timeutils_seconds_since_2000_to_struct_time(secs, &tmp); + tm->tm_wday = tmp.tm_wday; + tm->tm_yday = tmp.tm_yday; + + mp_obj_t elems[9] = { + mp_obj_new_int(tm->tm_year), + mp_obj_new_int(tm->tm_mon), + mp_obj_new_int(tm->tm_mday), + mp_obj_new_int(tm->tm_hour), + mp_obj_new_int(tm->tm_min), + mp_obj_new_int(tm->tm_sec), + mp_obj_new_int(tm->tm_wday), + mp_obj_new_int(tm->tm_yday), + mp_obj_new_int(-1), // tm_isdst is not supported + }; + + return namedtuple_make_new((const mp_obj_type_t*)&struct_time_type_obj, 9, 0, elems); +}; + +void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm) { + mp_obj_t *elems; + size_t len; + + if (!MP_OBJ_IS_TYPE(t, &mp_type_tuple) && !MP_OBJ_IS_TYPE(t, MP_OBJ_FROM_PTR(&struct_time_type_obj))) { + mp_raise_TypeError("Tuple or struct_time argument required"); + } + + mp_obj_tuple_get(t, &len, &elems); + if (len != 9) { + mp_raise_TypeError("function takes exactly 9 arguments"); + } + + tm->tm_year = mp_obj_get_int(elems[0]); + tm->tm_mon = mp_obj_get_int(elems[1]); + tm->tm_mday = mp_obj_get_int(elems[2]); + tm->tm_hour = mp_obj_get_int(elems[3]); + tm->tm_min = mp_obj_get_int(elems[4]); + tm->tm_sec = mp_obj_get_int(elems[5]); + tm->tm_wday = mp_obj_get_int(elems[6]); + tm->tm_yday = mp_obj_get_int(elems[7]); + // elems[8] tm_isdst is not supported +} + +mp_obj_t MP_WEAK rtc_get_time_source_time(void) { + mp_raise_RuntimeError("RTC is not supported on this board"); +} + +//| .. method:: time() +//| +//| Return the current time in seconds since since Jan 1, 2000. +//| +//| :return: the current time +//| :rtype: int +//| +STATIC mp_obj_t time_time(void) { + timeutils_struct_time_t tm; + struct_time_to_tm(rtc_get_time_source_time(), &tm); + mp_uint_t secs = timeutils_seconds_since_2000(tm.tm_year, tm.tm_mon, tm.tm_mday, // mp_uint_t date + tm.tm_hour, tm.tm_min, tm.tm_sec); + return mp_obj_new_int_from_uint(secs); +} +MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); + +//| .. method:: localtime([secs]) +//| +//| Convert a time expressed in seconds since Jan 1, 2000 to a struct_time in +//| local time. If secs is not provided or None, the current time as returned +//| by time() is used. +//| +//| :return: the current time +//| :rtype: time.struct_time +//| +STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) { + if (n_args == 0 || args[0] == mp_const_none) { + return rtc_get_time_source_time(); + } + + timeutils_struct_time_t tm; + timeutils_seconds_since_2000_to_struct_time(mp_obj_get_int(args[0]), &tm); + + return struct_time_from_tm(&tm); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(time_localtime_obj, 0, 1, time_localtime); + +//| .. method:: mktime(t) +//| +//| This is the inverse function of localtime(). Its argument is the +//| struct_time or full 9-tuple (since the dst flag is needed; use -1 as the +//| dst flag if it is unknown) which expresses the time in local time, not UTC. +//| The earliest date for which it can generate a time is Jan 1, 2000. +//| +//| :return: seconds +//| :rtype: int +//| +STATIC mp_obj_t time_mktime(mp_obj_t t) { + mp_obj_t *elem; + size_t len; + + if (!MP_OBJ_IS_TYPE(t, &mp_type_tuple) && !MP_OBJ_IS_TYPE(t, MP_OBJ_FROM_PTR(&struct_time_type_obj))) { + mp_raise_TypeError("Tuple or struct_time argument required"); + } + + mp_obj_tuple_get(t, &len, &elem); + if (len != 9) { + mp_raise_TypeError("function takes exactly 9 arguments"); + } + + return mp_obj_new_int_from_uint(timeutils_mktime(mp_obj_get_int(elem[0]), mp_obj_get_int(elem[1]), mp_obj_get_int(elem[2]), + mp_obj_get_int(elem[3]), mp_obj_get_int(elem[4]), mp_obj_get_int(elem[5]))); +} +MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime); #endif STATIC const mp_rom_map_elem_t time_module_globals_table[] = { @@ -142,7 +260,10 @@ STATIC const mp_rom_map_elem_t time_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&time_sleep_obj) }, #if MICROPY_PY_COLLECTIONS { MP_ROM_QSTR(MP_QSTR_struct_time), MP_ROM_PTR(&struct_time_type_obj) }, + { MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&time_localtime_obj) }, + { MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&time_mktime_obj) }, #endif + { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&time_time_obj) }, }; STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table); diff --git a/shared-bindings/time/__init__.h b/shared-bindings/time/__init__.h index f6ecb5989c..c5a0b47fc1 100644 --- a/shared-bindings/time/__init__.h +++ b/shared-bindings/time/__init__.h @@ -30,6 +30,11 @@ #include #include +#include "lib/timeutils/timeutils.h" + +extern mp_obj_t struct_time_from_tm(timeutils_struct_time_t *tm); +extern void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm); + extern uint64_t common_hal_time_monotonic(void); extern void common_hal_time_delay_ms(uint32_t); From 8e2080411f65598b1b704f829bc2761455265f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Sat, 7 Apr 2018 15:10:39 +0200 Subject: [PATCH 2/4] atmel-samd: Add rtc module support Support the rtc module by using hal_calendar. --- ports/atmel-samd/Makefile | 4 + ports/atmel-samd/asf4 | 2 +- .../asf4_conf/samd21/hpl_gclk_config.h | 10 +- .../asf4_conf/samd21/hpl_rtc_config.h | 10 +- .../asf4_conf/samd21/hpl_sysctrl_config.h | 12 +-- .../asf4_conf/samd21/peripheral_clk_config.h | 2 +- .../asf4_conf/samd51/hpl_gclk_config.h | 8 +- .../asf4_conf/samd51/hpl_osc32kctrl_config.h | 12 +-- .../asf4_conf/samd51/hpl_rtc_config.h | 10 +- ports/atmel-samd/common-hal/rtc/RTC.c | 98 +++++++++++++++++++ ports/atmel-samd/common-hal/rtc/RTC.h | 32 ++++++ ports/atmel-samd/common-hal/rtc/__init__.c | 0 ports/atmel-samd/mpconfigport.h | 3 + ports/atmel-samd/supervisor/port.c | 4 + 14 files changed, 182 insertions(+), 25 deletions(-) create mode 100644 ports/atmel-samd/common-hal/rtc/RTC.c create mode 100644 ports/atmel-samd/common-hal/rtc/RTC.h create mode 100644 ports/atmel-samd/common-hal/rtc/__init__.c diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 7d2982ca0d..73f1829e7f 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -39,6 +39,7 @@ INC += -I. \ -Iasf4/$(CHIP_FAMILY)/hpl/gclk \ -Iasf4/$(CHIP_FAMILY)/hpl/pm \ -Iasf4/$(CHIP_FAMILY)/hpl/port \ + -Iasf4/$(CHIP_FAMILY)/hpl/rtc \ -Iasf4/$(CHIP_FAMILY)/hpl/tc \ -Iasf4/$(CHIP_FAMILY)/include \ -Iasf4/$(CHIP_FAMILY)/CMSIS/Include \ @@ -173,6 +174,7 @@ SRC_ASF := \ gcc/system_$(CHIP_FAMILY).c \ hal/src/hal_adc_sync.c \ hal/src/hal_atomic.c \ + hal/src/hal_calendar.c \ hal/src/hal_dac_sync.c \ hal/src/hal_delay.c \ hal/src/hal_flash.c \ @@ -278,6 +280,8 @@ SRC_COMMON_HAL = \ microcontroller/Processor.c \ neopixel_write/__init__.c \ os/__init__.c \ + rtc/__init__.c \ + rtc/RTC.c \ storage/__init__.c \ supervisor/__init__.c \ supervisor/Runtime.c \ diff --git a/ports/atmel-samd/asf4 b/ports/atmel-samd/asf4 index aaa0f42811..02e264253c 160000 --- a/ports/atmel-samd/asf4 +++ b/ports/atmel-samd/asf4 @@ -1 +1 @@ -Subproject commit aaa0f428111fbea7d56ab548053b11c9f12068f1 +Subproject commit 02e264253c76b85c567ecdfce69ad0de0970da63 diff --git a/ports/atmel-samd/asf4_conf/samd21/hpl_gclk_config.h b/ports/atmel-samd/asf4_conf/samd21/hpl_gclk_config.h index d4c9bf2abe..230f6e6188 100644 --- a/ports/atmel-samd/asf4_conf/samd21/hpl_gclk_config.h +++ b/ports/atmel-samd/asf4_conf/samd21/hpl_gclk_config.h @@ -190,7 +190,7 @@ // Indicates whether generic clock 2 configuration is enabled or not // enable_gclk_gen_2 #ifndef CONF_GCLK_GENERATOR_2_CONFIG -#define CONF_GCLK_GENERATOR_2_CONFIG 0 +#define CONF_GCLK_GENERATOR_2_CONFIG 1 #endif // Generic Clock Generator Control @@ -205,7 +205,7 @@ // Indicates whether Divide Selection is enabled or not // gclk_gen_2_div_sel #ifndef CONF_GCLK_GEN_2_DIVSEL -#define CONF_GCLK_GEN_2_DIVSEL 0 +#define CONF_GCLK_GEN_2_DIVSEL 1 #endif // Output Enable @@ -233,7 +233,7 @@ // Indicates whether Generic Clock Generator Enable is enabled or not // gclk_arch_gen_2_enable #ifndef CONF_GCLK_GEN_2_GENEN -#define CONF_GCLK_GEN_2_GENEN 0 +#define CONF_GCLK_GEN_2_GENEN 1 #endif // Generic clock generator 2 source @@ -259,7 +259,7 @@ // This defines the clock source for generic clock generator 2 // gclk_gen_2_oscillator #ifndef CONF_GCLK_GEN_2_SRC -#define CONF_GCLK_GEN_2_SRC GCLK_GENCTRL_SRC_OSC32K +#define CONF_GCLK_GEN_2_SRC GCLK_GENCTRL_SRC_XOSC32K #endif // @@ -268,7 +268,7 @@ // // gclk_gen_2_div #ifndef CONF_GCLK_GEN_2_DIV -#define CONF_GCLK_GEN_2_DIV 1 +#define CONF_GCLK_GEN_2_DIV 4 #endif // diff --git a/ports/atmel-samd/asf4_conf/samd21/hpl_rtc_config.h b/ports/atmel-samd/asf4_conf/samd21/hpl_rtc_config.h index 929c70c8c6..7b77d90310 100644 --- a/ports/atmel-samd/asf4_conf/samd21/hpl_rtc_config.h +++ b/ports/atmel-samd/asf4_conf/samd21/hpl_rtc_config.h @@ -10,6 +10,14 @@ #define CONF_RTC_ENABLE 1 #endif +// Force reset RTC on initialization +// Force RTC to reset on initialization, else init is not going on if RTC is already enabled. +// Note that the previous power down data in RTC is lost if it's enabled. +// rtc_arch_init_reset +#ifndef CONF_RTC_INIT_RESET +#define CONF_RTC_INIT_RESET 0 +#endif + // Prescaler configuration // <0x0=>Peripheral clock divided by 1 // <0x1=>Peripheral clock divided by 2 @@ -25,7 +33,7 @@ // These bits define the RTC clock relative to the peripheral clock // rtc_arch_prescaler #ifndef CONF_RTC_PRESCALER -#define CONF_RTC_PRESCALER 0x0 +#define CONF_RTC_PRESCALER 0xa #endif diff --git a/ports/atmel-samd/asf4_conf/samd21/hpl_sysctrl_config.h b/ports/atmel-samd/asf4_conf/samd21/hpl_sysctrl_config.h index 389aefff3c..eaec93811f 100644 --- a/ports/atmel-samd/asf4_conf/samd21/hpl_sysctrl_config.h +++ b/ports/atmel-samd/asf4_conf/samd21/hpl_sysctrl_config.h @@ -197,7 +197,7 @@ // Indicates whether configuration for External 32K Osc is enabled or not // enable_xosc32k #ifndef CONF_XOSC32K_CONFIG -#define CONF_XOSC32K_CONFIG 0 +#define CONF_XOSC32K_CONFIG 1 #endif // 32kHz External Crystal Oscillator (XOSC32K) Control @@ -205,7 +205,7 @@ // Indicates whether External 32K Oscillator is enabled or not // xosc32k_arch_enable #ifndef CONF_XOSC32K_ENABLE -#define CONF_XOSC32K_ENABLE 0 +#define CONF_XOSC32K_ENABLE 1 #endif // On Demand @@ -223,7 +223,7 @@ // If this bit is 1: The oscillator is not stopped in standby sleep mode. // xosc32k_arch_runstdby #ifndef CONF_XOSC32K_RUNSTDBY -#define CONF_XOSC32K_RUNSTDBY 0 +#define CONF_XOSC32K_RUNSTDBY 1 #endif // Enable 1K @@ -237,14 +237,14 @@ // Enable 32 Khz Output // xosc32k_arch_en32k #ifndef CONF_XOSC32K_EN32K -#define CONF_XOSC32K_EN32K 0 +#define CONF_XOSC32K_EN32K 1 #endif // Enable XTAL // Enable XTAL // xosc32k_arch_xtalen #ifndef CONF_XOSC32K_XTALEN -#define CONF_XOSC32K_XTALEN 0 +#define CONF_XOSC32K_XTALEN 1 #endif // Write Lock @@ -274,7 +274,7 @@ // Default: 122 us // xosc32k_arch_startup #ifndef CONF_XOSC32K_STARTUP -#define CONF_XOSC32K_STARTUP CONF_XOSC32K_STARTUP_TIME_122MCS +#define CONF_XOSC32K_STARTUP CONF_XOSC32K_STARTUP_TIME_2000092MCS #endif // diff --git a/ports/atmel-samd/asf4_conf/samd21/peripheral_clk_config.h b/ports/atmel-samd/asf4_conf/samd21/peripheral_clk_config.h index cb7dad2041..f472776028 100644 --- a/ports/atmel-samd/asf4_conf/samd21/peripheral_clk_config.h +++ b/ports/atmel-samd/asf4_conf/samd21/peripheral_clk_config.h @@ -321,7 +321,7 @@ // Select the clock source for RTC. #ifndef CONF_GCLK_RTC_SRC -#define CONF_GCLK_RTC_SRC GCLK_CLKCTRL_GEN_GCLK0_Val +#define CONF_GCLK_RTC_SRC GCLK_CLKCTRL_GEN_GCLK2_Val #endif /** diff --git a/ports/atmel-samd/asf4_conf/samd51/hpl_gclk_config.h b/ports/atmel-samd/asf4_conf/samd51/hpl_gclk_config.h index 77793b69a5..3e41d21682 100644 --- a/ports/atmel-samd/asf4_conf/samd51/hpl_gclk_config.h +++ b/ports/atmel-samd/asf4_conf/samd51/hpl_gclk_config.h @@ -172,7 +172,7 @@ // Indicates whether generic clock 2 configuration is enabled or not // enable_gclk_gen_2 #ifndef CONF_GCLK_GENERATOR_2_CONFIG -#define CONF_GCLK_GENERATOR_2_CONFIG 0 +#define CONF_GCLK_GENERATOR_2_CONFIG 1 #endif // Generic Clock Generator Control @@ -188,7 +188,7 @@ // This defines the clock source for generic clock generator 2 // gclk_gen_2_oscillator #ifndef CONF_GCLK_GEN_2_SOURCE -#define CONF_GCLK_GEN_2_SOURCE GCLK_GENCTRL_SRC_XOSC1 +#define CONF_GCLK_GEN_2_SOURCE GCLK_GENCTRL_SRC_XOSC32K #endif // Run in Standby @@ -230,7 +230,7 @@ // Indicates whether Generic Clock Generator Enable is enabled or not // gclk_arch_gen_2_enable #ifndef CONF_GCLK_GEN_2_GENEN -#define CONF_GCLK_GEN_2_GENEN 0 +#define CONF_GCLK_GEN_2_GENEN 1 #endif // @@ -238,7 +238,7 @@ // Generic clock generator 2 division <0x0000-0xFFFF> // gclk_gen_2_div #ifndef CONF_GCLK_GEN_2_DIV -#define CONF_GCLK_GEN_2_DIV 1 +#define CONF_GCLK_GEN_2_DIV 4 #endif // // diff --git a/ports/atmel-samd/asf4_conf/samd51/hpl_osc32kctrl_config.h b/ports/atmel-samd/asf4_conf/samd51/hpl_osc32kctrl_config.h index ccb2627480..73128077ca 100644 --- a/ports/atmel-samd/asf4_conf/samd51/hpl_osc32kctrl_config.h +++ b/ports/atmel-samd/asf4_conf/samd51/hpl_osc32kctrl_config.h @@ -23,7 +23,7 @@ // Use 1 kHz output // rtc_1khz_selection #ifndef CONF_RTCCTRL_1KHZ -#define CONF_RTCCTRL_1KHZ 1 +#define CONF_RTCCTRL_1KHZ 0 #endif #if CONF_RTCCTRL_SRC == GCLK_GENCTRL_SRC_OSCULP32K @@ -62,7 +62,7 @@ // <0x6=>8000092us // xosc32k_arch_startup #ifndef CONF_XOSC32K_STARTUP -#define CONF_XOSC32K_STARTUP 0x0 +#define CONF_XOSC32K_STARTUP 0x4 #endif // On Demand Control @@ -76,7 +76,7 @@ // Indicates whether Run in Standby is enabled or not // xosc32k_arch_runstdby #ifndef CONF_XOSC32K_RUNSTDBY -#define CONF_XOSC32K_RUNSTDBY 0 +#define CONF_XOSC32K_RUNSTDBY 1 #endif // 1kHz Output Enable @@ -90,7 +90,7 @@ // Indicates whether 32kHz Output is enabled or not // xosc32k_arch_en32k #ifndef CONF_XOSC32K_EN32K -#define CONF_XOSC32K_EN32K 0 +#define CONF_XOSC32K_EN32K 1 #endif // Clock Switch Back @@ -118,7 +118,7 @@ // Indicates whether the connections between the I/O pads and the external clock or crystal oscillator is enabled or not // xosc32k_arch_xtalen #ifndef CONF_XOSC32K_XTALEN -#define CONF_XOSC32K_XTALEN 0 +#define CONF_XOSC32K_XTALEN 1 #endif // Control Gain Mode @@ -137,7 +137,7 @@ // Indicates whether configuration for OSCULP32K is enabled or not // enable_osculp32k #ifndef CONF_OSCULP32K_CONFIG -#define CONF_OSCULP32K_CONFIG 1 +#define CONF_OSCULP32K_CONFIG 0 #endif // 32kHz Ultra Low Power Internal Oscillator Control diff --git a/ports/atmel-samd/asf4_conf/samd51/hpl_rtc_config.h b/ports/atmel-samd/asf4_conf/samd51/hpl_rtc_config.h index b99821da5b..2b0b6712e6 100644 --- a/ports/atmel-samd/asf4_conf/samd51/hpl_rtc_config.h +++ b/ports/atmel-samd/asf4_conf/samd51/hpl_rtc_config.h @@ -10,6 +10,14 @@ #define CONF_RTC_ENABLE 1 #endif +// Force reset RTC on initialization +// Force RTC to reset on initialization. +// Note that the previous power down data in RTC is lost if it's enabled. +// rtc_arch_init_reset +#ifndef CONF_RTC_INIT_RESET +#define CONF_RTC_INIT_RESET 0 +#endif + // Prescaler configuration // <0x0=>OFF(Peripheral clock divided by 1) // <0x1=>Peripheral clock divided by 1 @@ -26,7 +34,7 @@ // These bits define the RTC clock relative to the peripheral clock // rtc_arch_prescaler #ifndef CONF_RTC_PRESCALER -#define CONF_RTC_PRESCALER 0x0 +#define CONF_RTC_PRESCALER 0xb #endif diff --git a/ports/atmel-samd/common-hal/rtc/RTC.c b/ports/atmel-samd/common-hal/rtc/RTC.c new file mode 100644 index 0000000000..d63e81305d --- /dev/null +++ b/ports/atmel-samd/common-hal/rtc/RTC.c @@ -0,0 +1,98 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Noralf Trønnes + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include +#include +#include +#include +#include + +#include "py/obj.h" +#include "py/runtime.h" +#include "lib/timeutils/timeutils.h" +#include "shared-bindings/rtc/__init__.h" + +static struct calendar_descriptor calendar; + +void rtc_init(void) { +#ifdef SAMD21 + _gclk_enable_channel(RTC_GCLK_ID, CONF_GCLK_RTC_SRC); +#endif +#ifdef SAMD51 + hri_mclk_set_APBAMASK_RTC_bit(MCLK); +#endif + calendar_init(&calendar, RTC); + calendar_set_baseyear(&calendar, 2000); + calendar_enable(&calendar); +} + +void common_hal_rtc_get_time(timeutils_struct_time_t *tm) { + struct calendar_date_time datetime; + calendar_get_date_time(&calendar, &datetime); + + tm->tm_year = datetime.date.year; + tm->tm_mon = datetime.date.month; + tm->tm_mday = datetime.date.day; + tm->tm_hour = datetime.time.hour; + tm->tm_min = datetime.time.min; + tm->tm_sec = datetime.time.sec; +} + +void common_hal_rtc_set_time(timeutils_struct_time_t *tm) { + struct calendar_date date = { + .year = tm->tm_year, + .month = tm->tm_mon, + .day = tm->tm_mday, + }; + calendar_set_date(&calendar, &date); + + struct calendar_time time = { + .hour = tm->tm_hour, + .min = tm->tm_min, + .sec = tm->tm_sec, + }; + calendar_set_time(&calendar, &time); +} + +// A positive value speeds up the clock by removing clock cycles. +int common_hal_rtc_get_calibration(void) { + int calibration = hri_rtcmode0_read_FREQCORR_VALUE_bf(calendar.device.hw); + + if (!hri_rtcmode0_get_FREQCORR_SIGN_bit(calendar.device.hw)) + calibration = -calibration; + + return calibration; +} + +void common_hal_rtc_set_calibration(int calibration) { + if (calibration > 127 || calibration < -127) + mp_raise_ValueError("calibration value out of range +/-127"); + + hri_rtcmode0_write_FREQCORR_SIGN_bit(calendar.device.hw, calibration < 0 ? 0 : 1); + hri_rtcmode0_write_FREQCORR_VALUE_bf(calendar.device.hw, abs(calibration)); +} diff --git a/ports/atmel-samd/common-hal/rtc/RTC.h b/ports/atmel-samd/common-hal/rtc/RTC.h new file mode 100644 index 0000000000..1d63b2deac --- /dev/null +++ b/ports/atmel-samd/common-hal/rtc/RTC.h @@ -0,0 +1,32 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Noralf Trønnes + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RTC_RTC_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RTC_RTC_H + +extern void rtc_init(void); + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RTC_RTC_H diff --git a/ports/atmel-samd/common-hal/rtc/__init__.c b/ports/atmel-samd/common-hal/rtc/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 7dbcd50626..5ac06944ad 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -166,6 +166,7 @@ extern const struct _mp_obj_module_t board_module; extern const struct _mp_obj_module_t math_module; extern const struct _mp_obj_module_t os_module; extern const struct _mp_obj_module_t random_module; +extern const struct _mp_obj_module_t rtc_module; extern const struct _mp_obj_module_t storage_module; extern const struct _mp_obj_module_t struct_module; extern const struct _mp_obj_module_t time_module; @@ -234,6 +235,7 @@ extern const struct _mp_obj_module_t usb_hid_module; { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_rtc), (mp_obj_t)&rtc_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&struct_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_supervisor), (mp_obj_t)&supervisor_module }, \ @@ -266,6 +268,7 @@ extern const struct _mp_obj_module_t usb_hid_module; const char *readline_hist[8]; \ vstr_t *repl_line; \ mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT]; \ + mp_obj_t rtc_time_source; \ FLASH_ROOT_POINTERS \ void run_background_tasks(void); diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index eafb9b7857..20a21f8279 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -52,7 +52,9 @@ #include "common-hal/pulseio/PulseIn.h" #include "common-hal/pulseio/PulseOut.h" #include "common-hal/pulseio/PWMOut.h" +#include "common-hal/rtc/RTC.h" #include "common-hal/usb_hid/Device.h" +#include "shared-bindings/rtc/__init__.h" #include "clocks.h" #include "events.h" #include "shared_dma.h" @@ -124,6 +126,7 @@ safe_mode_t port_init(void) { // Configure millisecond timer initialization. tick_init(); + rtc_init(); // Init the nvm controller. // struct nvm_config config_nvm; @@ -209,6 +212,7 @@ void reset_port(void) { pulsein_reset(); pulseout_reset(); pwmout_reset(); + rtc_reset(); reset_gclks(); From 84d4be279e629f4094d9e72770e807bd1bb166f6 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 16 Apr 2018 15:00:01 -0700 Subject: [PATCH 3/4] Add a table of contents reference to RTC --- shared-bindings/rtc/__init__.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shared-bindings/rtc/__init__.c b/shared-bindings/rtc/__init__.c index 89e3a24dd2..ac67a7131c 100644 --- a/shared-bindings/rtc/__init__.c +++ b/shared-bindings/rtc/__init__.c @@ -41,6 +41,13 @@ //| The `rtc` module provides support for a Real Time Clock. //| It also backs the `time.time()` and `time.localtime()` functions using the onboard RTC if present. //| +//| Libraries +//| +//| .. toctree:: +//| :maxdepth: 3 +//| +//| RTC +//| void rtc_reset(void) { MP_STATE_VM(rtc_time_source) = (mp_obj_t)&rtc_rtc_obj; From 301479cd44426ade10aef3d0e685d496ea3a7c3d Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 16 Apr 2018 15:00:58 -0700 Subject: [PATCH 4/4] Remove "Get or set" --- shared-bindings/rtc/RTC.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index 30df20145d..aeedad12d9 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -72,7 +72,7 @@ STATIC mp_obj_t rtc_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_ //| .. attribute:: datetime //| -//| Get or set the date and time of the RTC. +//| The date and time of the RTC. //| STATIC mp_obj_t rtc_rtc_obj_get_datetime(mp_obj_t self_in) { timeutils_struct_time_t tm;