Skip to content

Commit d721f0d

Browse files
committed
Fixed error when building without telnet and/or ftp module
1 parent f2b25e2 commit d721f0d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

MicroPython_BUILD/components/micropython/esp32/machine_timer.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ typedef struct _machine_timer_obj_t {
6060
uint8_t state;
6161
uint8_t type;
6262
int8_t debug_pin;
63+
int8_t debug_pin_mode;
6364
mp_uint_t repeat;
6465
mp_uint_t period;
6566
uint64_t event_num;
@@ -215,7 +216,10 @@ STATIC void machine_timer_isr(void *self_in)
215216
TIMERG0.hw_timer[self->id & 1].config.alarm_en = self->repeat;
216217
}
217218

218-
if (self->debug_pin >= 0) gpio_set_level(self->debug_pin, (self->event_num & 1));
219+
if (self->debug_pin >= 0) {
220+
if (self->debug_pin_mode >= 0) gpio_set_level(self->debug_pin, (self->debug_pin_mode & 1));
221+
else gpio_set_level(self->debug_pin, (self->event_num & 1));
222+
}
219223
self->event_num++;
220224

221225
if ((self->callback) && (mp_sched_schedule(self->callback, self, NULL))) self->cb_num++;
@@ -313,6 +317,7 @@ STATIC mp_obj_t machine_timer_init_helper(machine_timer_obj_t *self, mp_uint_t n
313317
{ MP_QSTR_mode, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = TIMER_TYPE_PERIODIC} },
314318
{ MP_QSTR_callback, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
315319
{ MP_QSTR_dbgpin, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
320+
{ MP_QSTR_dbgpinmode, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
316321
};
317322

318323
machine_timer_disable(self);
@@ -355,6 +360,7 @@ STATIC mp_obj_t machine_timer_init_helper(machine_timer_obj_t *self, mp_uint_t n
355360
// set the debug gpio if used
356361
if ((args[3].u_int >= 0) && (args[3].u_int < 34)) {
357362
self->debug_pin = args[3].u_int;
363+
self->debug_pin_mode = args[4].u_int;
358364
gpio_pad_select_gpio(self->debug_pin);
359365
gpio_set_direction(self->debug_pin, GPIO_MODE_OUTPUT);
360366
gpio_set_level(self->debug_pin, 0);

MicroPython_BUILD/components/micropython/py/modthread.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,20 +445,29 @@ STATIC mp_obj_t mod_thread_list(mp_uint_t n_args, const mp_obj_t *args) {
445445
thr->stack_max, th_type);
446446
}
447447
free(list.threads);
448+
#ifdef CONFIG_MICROPY_USE_TELNET
448449
if (TelnetTaskHandle) {
449450
mp_printf(&mp_plat_print, "ID=%u, Name: Telnet, Stack=%d, MaxUsed=%d, Type: SERVICE\n",
450451
TelnetTaskHandle, TELNET_STACK_LEN, TELNET_STACK_LEN - uxTaskGetStackHighWaterMark(TelnetTaskHandle));
451452
}
453+
#endif
454+
455+
#ifdef CONFIG_MICROPY_USE_FTPSERVER
452456
if (FtpTaskHandle) {
453457
mp_printf(&mp_plat_print, "ID=%u, Name: Ftp, Stack=%d, MaxUsed=%d, Type: SERVICE\n",
454458
FtpTaskHandle, FTP_STACK_LEN, FTP_STACK_LEN - uxTaskGetStackHighWaterMark(FtpTaskHandle));
455459
}
460+
#endif
456461
return mp_const_none;
457462
}
458463
else {
459464
int services = 0;
465+
#ifdef CONFIG_MICROPY_USE_TELNET
460466
if (TelnetTaskHandle) services++;
467+
#endif
468+
#ifdef CONFIG_MICROPY_USE_FTPSERVER
461469
if (FtpTaskHandle) services++;
470+
#endif
462471
mp_obj_t thr_info[6];
463472
mp_obj_t tuple[num+services];
464473
for (n=0; n<num; n++) {
@@ -474,6 +483,7 @@ STATIC mp_obj_t mod_thread_list(mp_uint_t n_args, const mp_obj_t *args) {
474483
tuple[n] = mp_obj_new_tuple(6, thr_info);
475484
}
476485
free(list.threads);
486+
#ifdef CONFIG_MICROPY_USE_TELNET
477487
if (TelnetTaskHandle) {
478488
thr_info[0] = mp_obj_new_int((int)TelnetTaskHandle);
479489
thr_info[1] = mp_obj_new_int(THREAD_TYPE_SERVICE);
@@ -484,6 +494,8 @@ STATIC mp_obj_t mod_thread_list(mp_uint_t n_args, const mp_obj_t *args) {
484494
tuple[n] = mp_obj_new_tuple(6, thr_info);
485495
n++;
486496
}
497+
#endif
498+
#ifdef CONFIG_MICROPY_USE_FTPSERVER
487499
if (FtpTaskHandle) {
488500
thr_info[0] = mp_obj_new_int((int)FtpTaskHandle);
489501
thr_info[1] = mp_obj_new_int(THREAD_TYPE_SERVICE);
@@ -494,6 +506,7 @@ STATIC mp_obj_t mod_thread_list(mp_uint_t n_args, const mp_obj_t *args) {
494506
tuple[n] = mp_obj_new_tuple(6, thr_info);
495507
n++;
496508
}
509+
#endif
497510

498511
return mp_obj_new_tuple(n, tuple);
499512
}

0 commit comments

Comments
 (0)