Skip to content

Commit 10c78e6

Browse files
author
huangpeng
committed
【修改】修改文件格式,使用空格代替tab,将注释改为英文
1 parent c28f818 commit 10c78e6

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

port/modules/machine/machine_timer.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ STATIC mp_obj_t machine_timer_init(mp_uint_t n_args, const mp_obj_t *args, mp_ma
166166
if (self->timeout_cb != RT_NULL) {
167167
// set callback timer
168168
if (timer_self[self->timer_device->device_id] && timer_self[self->timer_device->device_id] != self) {
169-
// TODO add multi-timer device support
170-
error_check(result == RT_EOK, "Only supports one timer device work");
169+
error_check(result == RT_EOK, "Timer device callback function already exists");
171170
} else {
172171
timer_self[self->timer_device->device_id] = self;
173172
}
@@ -213,22 +212,22 @@ STATIC mp_obj_t machine_timer_callback(mp_uint_t n_args, const mp_obj_t *args, m
213212

214213
if(n_args == 1)
215214
{
216-
self->timeout_cb = RT_NULL;
217-
self->timer_device->rx_indicate = RT_NULL;//注销回调函数
215+
self->timeout_cb = RT_NULL;
216+
self->timer_device->rx_indicate = RT_NULL;//Log-off callback function
218217
}
219218
else if(n_args == 2)
220219
{
221-
if(self->timeout_cb != mp_const_none)
222-
{
223-
timer_self[self->timer_device->device_id] = self;
224-
result = rt_device_set_rx_indicate(self->timer_device, timer_event_handler); //注册回调函数
225-
error_check(result == RT_EOK, "Timer set timout callback error");
226-
}
227-
else
228-
{
229-
self->timeout_cb = RT_NULL;
230-
self->timer_device->rx_indicate = RT_NULL;//注销回调函数
231-
}
220+
if(self->timeout_cb != mp_const_none)
221+
{
222+
timer_self[self->timer_device->device_id] = self;
223+
result = rt_device_set_rx_indicate(self->timer_device, timer_event_handler); //set callback timer
224+
error_check(result == RT_EOK, "Timer set timout callback error");
225+
}
226+
else
227+
{
228+
self->timeout_cb = RT_NULL;
229+
self->timer_device->rx_indicate = RT_NULL;//Log-off callback function
230+
}
232231
}
233232
return mp_const_none;
234233
}
@@ -237,7 +236,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_timer_callback_obj, 0,machine_timer_ca
237236
STATIC const mp_rom_map_elem_t machine_timer_locals_dict_table[] = {
238237
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&machine_timer_deinit_obj) },
239238
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_timer_init_obj) },
240-
{ MP_ROM_QSTR(MP_QSTR_callback), MP_ROM_PTR(&machine_timer_callback_obj) },
239+
{ MP_ROM_QSTR(MP_QSTR_callback), MP_ROM_PTR(&machine_timer_callback_obj) },
241240
{ MP_ROM_QSTR(MP_QSTR_ONE_SHOT), MP_ROM_INT(RT_FALSE) },
242241
{ MP_ROM_QSTR(MP_QSTR_PERIODIC), MP_ROM_INT(RT_TRUE) },
243242
};

0 commit comments

Comments
 (0)