Skip to content

fix busy() for Teensy4#37

Open
profezzorn wants to merge 1 commit intoPaulStoffregen:masterfrom
profezzorn:busy_fix
Open

fix busy() for Teensy4#37
profezzorn wants to merge 1 commit intoPaulStoffregen:masterfrom
profezzorn:busy_fix

Conversation

@profezzorn
Copy link
Copy Markdown

Looks like there is a missing return statement.
This PR fixes that.

@Satak
Copy link
Copy Markdown

Satak commented Dec 8, 2024

May I ask @PaulStoffregen why this PR was never merged? I asked copilot about this function and it gave similar suggestion.

The function int OctoWS2811::busy(void) has a potential bug due to an empty statement after the first if condition. Here is the problematic code:

if (!dma3.complete()) ; // DMA still running
if (micros() - update_begin_micros < numbytes * 10 + 300) return 1; // WS2812 reset
The first if condition checks if dma3 is complete but does nothing because of the semicolon (;). This means the function does not properly check if DMA is still running. Removing the semicolon should fix the issue:

if (!dma3.complete()) return 1; // DMA still running
if (micros() - update_begin_micros < numbytes * 10 + 300) return 1; // WS2812 reset
Now, the function will return 1 if DMA is still running or if the WS2812 reset time has not elapsed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants