Skip to content

Commit f9b9223

Browse files
committed
Fix bound checks in analogWriteFrequency
1 parent 4bb465d commit f9b9223

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cores/arduino/sdk/core-implement/CommonAnalog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,11 @@ ap3_err_t analogWriteFrameWidth(uint32_t width){
213213

214214
ap3_err_t analogWriteFrequency(float freq){
215215
uint32_t new_width = (uint32_t)(AP3_ANALOG_CLK_FREQ / freq);
216+
216217
if (new_width > AP3_MAX_ANALOG_WRITE_WIDTH){
217218
return AP3_ERR;
218219
}
219-
if (new_width < AP3_MAX_ANALOG_WRITE_WIDTH){
220+
if (new_width < AP3_MIN_ANALOG_WRITE_WIDTH){
220221
return AP3_ERR;
221222
}
222223
_analogWriteWidth = new_width;

0 commit comments

Comments
 (0)