Skip to content

Commit 78258cb

Browse files
KurtEfacchinm
authored andcommitted
analogWrite - don't fault if you pass in pin number that is not setup for PWM
The code was already there, but before it checked that the index was valid it first checked if the pwm was ready, So moved the check up before that.
1 parent b82fb54 commit 78258cb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: cores/arduino/zephyrCommon.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,11 @@ void analogWrite(pin_size_t pinNumber, int value)
282282
{
283283
size_t idx = pwm_pin_index(pinNumber);
284284

285-
if (!pwm_is_ready_dt(&arduino_pwm[idx])) {
285+
if (idx >= ARRAY_SIZE(arduino_pwm) ) {
286286
return;
287287
}
288288

289-
if (idx >= ARRAY_SIZE(arduino_pwm) ) {
289+
if (!pwm_is_ready_dt(&arduino_pwm[idx])) {
290290
return;
291291
}
292292

0 commit comments

Comments
 (0)