Skip to content

Commit 2a5d220

Browse files
IhorNehrutsaIhorNehrutsa
IhorNehrutsa
authored and
IhorNehrutsa
committed
esp32: Allow to use the DEBUG_printf.
1 parent 057701a commit 2a5d220

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

ports/esp32/machine_pwm.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@
3636
#include "esp_err.h"
3737
#include "soc/gpio_sig_map.h"
3838

39-
#define PWM_DBG(...)
40-
// #define PWM_DBG(...) mp_printf(&mp_plat_print, __VA_ARGS__); mp_printf(&mp_plat_print, "\n");
39+
#if 0 // print debugging info
40+
#define DEBUG_printf DEBUG_printf
41+
#else // don't print debugging info
42+
#define DEBUG_printf(...) (void)0
43+
#endif
4144

4245
// Total number of channels
4346
#define PWM_CHANNEL_MAX (LEDC_SPEED_MODE_MAX * LEDC_CHANNEL_MAX)
@@ -348,10 +351,10 @@ STATIC void set_duty_u16(machine_pwm_obj_t *self, int duty) {
348351
// Bug: It has been experimentally established that the duty is set during 2 signal periods, but 1 period is expected.
349352
// See https://github.com/espressif/esp-idf/issues/7288
350353
if (duty != get_duty_u16(self)) {
351-
PWM_DBG("set_duty_u16(%u), get_duty_u16():%u, channel_duty:%d, duty_resolution:%d, freq_hz:%d", duty, get_duty_u16(self), channel_duty, timer.duty_resolution, timer.freq_hz);
354+
DEBUG_printf("set_duty_u16(%u), get_duty_u16():%u, channel_duty:%d, duty_resolution:%d, freq_hz:%d\n", duty, get_duty_u16(self), channel_duty, timer.duty_resolution, timer.freq_hz);
352355
esp_rom_delay_us(2 * 1000000 / timer.freq_hz);
353356
if (duty != get_duty_u16(self)) {
354-
PWM_DBG("set_duty_u16(%u), get_duty_u16():%u, channel_duty:%d, duty_resolution:%d, freq_hz:%d", duty, get_duty_u16(self), channel_duty, timer.duty_resolution, timer.freq_hz);
357+
DEBUG_printf("set_duty_u16(%u), get_duty_u16():%u, channel_duty:%d, duty_resolution:%d, freq_hz:%d\n", duty, get_duty_u16(self), channel_duty, timer.duty_resolution, timer.freq_hz);
355358
}
356359
}
357360
*/

ports/esp32/mpconfigport.h

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#define MICROPY_STREAMS_POSIX_API (1)
7070
#define MICROPY_USE_INTERNAL_ERRNO (0) // errno.h from xtensa-esp32-elf/sys-include/sys
7171
#define MICROPY_USE_INTERNAL_PRINTF (0) // ESP32 SDK requires its own printf
72+
#define MICROPY_DEBUG_PRINTERS (1)
7273
#define MICROPY_SCHEDULER_DEPTH (8)
7374
#define MICROPY_VFS (1)
7475

0 commit comments

Comments
 (0)