@@ -54,7 +54,7 @@ typedef struct _machine_timer_obj_t {
54
54
mp_uint_t index ;
55
55
56
56
mp_uint_t repeat ;
57
- // ESP32 timers are 64-bit
57
+ // ESP32 timers are 64 or 54 -bit
58
58
uint64_t period ;
59
59
60
60
mp_obj_t callback ;
@@ -84,13 +84,22 @@ static void machine_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
84
84
machine_timer_obj_t * self = self_in ;
85
85
qstr mode = self -> repeat ? MP_QSTR_PERIODIC : MP_QSTR_ONE_SHOT ;
86
86
uint64_t period = self -> period / (TIMER_SCALE / 1000 ); // convert to ms
87
+ #if CONFIG_IDF_TARGET_ESP32C3
88
+ mp_printf (print , "Timer(%u, mode=%q, period=%lu)" , self -> group , mode , period );
89
+ #else
87
90
mp_printf (print , "Timer(%u, mode=%q, period=%lu)" , (self -> group << 1 ) | self -> index , mode , period );
91
+ #endif
88
92
}
89
93
90
94
static mp_obj_t machine_timer_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
91
95
mp_arg_check_num (n_args , n_kw , 1 , MP_OBJ_FUN_ARGS_MAX , true);
96
+ #if CONFIG_IDF_TARGET_ESP32C3
97
+ mp_uint_t group = mp_obj_get_int (args [0 ]) & 1 ;
98
+ mp_uint_t index = 0 ;
99
+ #else
92
100
mp_uint_t group = (mp_obj_get_int (args [0 ]) >> 1 ) & 1 ;
93
101
mp_uint_t index = mp_obj_get_int (args [0 ]) & 1 ;
102
+ #endif
94
103
95
104
machine_timer_obj_t * self = NULL ;
96
105
0 commit comments