Skip to content

Commit 9dfc88b

Browse files
IhorNehrutsaIhorNehrutsa
IhorNehrutsa
authored andcommitted
esp32: Allow to use the DEBUG_printf.
Signed-off-by: IhorNehrutsa <[email protected]>
1 parent 057701a commit 9dfc88b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-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
*/

0 commit comments

Comments
 (0)