Skip to content
This repository was archived by the owner on Apr 25, 2021. It is now read-only.

Commit 12ad3fa

Browse files
committed
signal_hook 에서 대기 시간(tick)을 인자로 받음 (mp_hal_delay_ms, Signal_Hook 함수에서 인자 전달함)
1 parent 8971339 commit 12ad3fa

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/machine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void Reset_Handler(void) {
4949

5050

5151
STATIC mp_obj_t signal_hook0(mp_obj_t none_obj) {
52-
mp_call_function_0(signal_hook_obj);
52+
mp_call_function_1(signal_hook_obj, MP_OBJ_NEW_SMALL_INT(0));
5353
return mp_const_none;
5454
}
5555

src/mphalport.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "mphalport.h"
88
#include "syscall.h"
99

10+
extern mp_obj_t signal_hook_obj;
1011
extern mp_obj_t input_hook_obj;
1112
extern mp_obj_t print_hook_obj;
1213

@@ -38,10 +39,13 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
3839

3940
void mp_hal_delay_ms(mp_uint_t ms) {
4041
uint32_t start = mp_hal_ticks_ms();
41-
extern void mp_handle_pending(void);
42-
while (mp_hal_ticks_ms() - start < ms) {
42+
uint32_t elapsed = 0;
43+
while (elapsed < ms) {
44+
elapsed = mp_hal_ticks_ms() - start;
4345
mp_handle_pending();
44-
// OPENPIE_CONTROLLER->IDLE = 1;
46+
int32_t ticks = (ms - elapsed) / (1000 / 20);
47+
mp_obj_t tick_obj = mp_obj_new_int(ticks < 0? 0 : ticks);
48+
mp_call_function_1(signal_hook_obj, tick_obj);
4549
}
4650
}
4751

0 commit comments

Comments
 (0)