@@ -71,6 +71,7 @@ typedef struct {
7171 ******************************************************************************/
7272STATIC pybrtc_data_t pybrtc_data ;
7373STATIC const mp_cb_methods_t pybrtc_cb_methods ;
74+ STATIC const mp_obj_base_t pyb_rtc_obj = {& pyb_rtc_type };
7475
7576/******************************************************************************
7677 DECLARE PUBLIC FUNCTIONS
@@ -123,6 +124,16 @@ STATIC void pyb_rtc_callback_enable (mp_obj_t self_in) {
123124/******************************************************************************/
124125// Micro Python bindings
125126
127+ /// \classmethod \constructor()
128+ /// Create an RTC object.
129+ STATIC mp_obj_t pyb_rtc_make_new (mp_obj_t type_in , mp_uint_t n_args , mp_uint_t n_kw , const mp_obj_t * args ) {
130+ // check arguments
131+ mp_arg_check_num (n_args , n_kw , 0 , 0 , false);
132+
133+ // return constant object
134+ return (mp_obj_t )& pyb_rtc_obj ;
135+ }
136+
126137/// \method datetime([datetimetuple])
127138/// Get or set the date and time of the RTC.
128139///
@@ -235,9 +246,10 @@ STATIC const mp_map_elem_t pyb_rtc_locals_dict_table[] = {
235246};
236247STATIC MP_DEFINE_CONST_DICT (pyb_rtc_locals_dict , pyb_rtc_locals_dict_table );
237248
238- STATIC const mp_obj_type_t pyb_rtc_type = {
249+ const mp_obj_type_t pyb_rtc_type = {
239250 { & mp_type_type },
240251 .name = MP_QSTR_RTC ,
252+ .make_new = pyb_rtc_make_new ,
241253 .locals_dict = (mp_obj_t )& pyb_rtc_locals_dict ,
242254};
243255
@@ -246,5 +258,3 @@ STATIC const mp_cb_methods_t pybrtc_cb_methods = {
246258 .enable = pyb_rtc_callback_enable ,
247259 .disable = pyb_rtc_callback_disable ,
248260};
249-
250- const mp_obj_base_t pyb_rtc_obj = {& pyb_rtc_type };
0 commit comments