Skip to content

Commit c7d00e0

Browse files
authored
fix(pio): broken bitReverse function (#87)
pretty self-explanatory, this is another bug I found while playing around with the PIOs. https://jsfiddle.net/bwn6j75r/ Cheers!
1 parent 833fea2 commit c7d00e0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/peripherals/pio.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ export enum WaitType {
8181
}
8282

8383
function bitReverse(x: number) {
84-
x = ((x & 0x55555555) << 1) | ((x & 0xaaaaaaaa) >> 1);
85-
x = ((x & 0x33333333) << 2) | ((x & 0xcccccccc) >> 2);
86-
x = ((x & 0x0f0f0f0f) << 4) | ((x & 0xf0f0f0f0) >> 4);
87-
x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
88-
x = ((x & 0x0000ffff) << 16) | ((x & 0xffff0000) >> 16);
84+
x = ((x & 0x55555555) << 1) | ((x & 0xaaaaaaaa) >>> 1);
85+
x = ((x & 0x33333333) << 2) | ((x & 0xcccccccc) >>> 2);
86+
x = ((x & 0x0f0f0f0f) << 4) | ((x & 0xf0f0f0f0) >>> 4);
87+
x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >>> 8);
88+
x = ((x & 0x0000ffff) << 16) | ((x & 0xffff0000) >>> 16);
8989
return x >>> 0;
9090
}
9191

0 commit comments

Comments
 (0)