Skip to content

Commit

Permalink
esp32/machine_pwm.c: Out of PWM timers/channels.
Browse files Browse the repository at this point in the history
Exception messages will print with light sleep context
(for ESP32 board)
"out of PWM timers:8"
or
"out of light sleep capable PWM timers:4"

"out of PWM channels:16"
or
"out of light sleep capable PWM channels:8"

Signed-off-by: Ihor Nehrutsa <[email protected]>
  • Loading branch information
IhorNehrutsa committed Feb 11, 2025
1 parent 559a98a commit c546bc6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ports/esp32/machine_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ static void select_timer(machine_pwm_obj_t *self, int freq) {
}
}
if (timer < 0) {
mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("out of PWM timers:%d"), self->light_sleep_enable ? LEDC_TIMER_MAX : LEDC_SPEED_MODE_MAX *LEDC_TIMER_MAX);
mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("out of %sPWM timers:%d"), self->light_sleep_enable ? "light sleep capable " : "", self->light_sleep_enable ? LEDC_TIMER_MAX : LEDC_SPEED_MODE_MAX *LEDC_TIMER_MAX);
}
// If the timer is found, then bind
if (self->timer != timer) {
Expand Down Expand Up @@ -609,7 +609,7 @@ static void mp_machine_pwm_init_helper(machine_pwm_obj_t *self,
int channel = -1;
find_channel(self, &mode, &channel);
if (channel < 0) {
mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("out of PWM channels:%d"), self->light_sleep_enable ? LEDC_CHANNEL_MAX : LEDC_SPEED_MODE_MAX *LEDC_CHANNEL_MAX); // in all modes
mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("out of %sPWM channels:%d"), self->light_sleep_enable ? "light sleep capable " : "", self->light_sleep_enable ? LEDC_CHANNEL_MAX : LEDC_SPEED_MODE_MAX *LEDC_CHANNEL_MAX);
}
self->mode = mode;
self->channel = channel;
Expand Down

0 comments on commit c546bc6

Please sign in to comment.