Skip to content

Commit b042c3a

Browse files
committed
Allign the buffer
1 parent dc136bf commit b042c3a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

usermods/user_fx/user_fx.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ static uint16_t mode_diffusionfire(void) {
3535
}
3636

3737
if ((strip.now - SEGENV.step) >= refresh_ms) {
38-
uint16_t *tmp_row = (uint16_t *)(SEGMENT.data + SEGMENT.length());
38+
// Reserve one extra byte and align to 2-byte boundary to avoid hard-faults
39+
uint8_t *bufStart = SEGMENT.data + SEGMENT.length();
40+
uintptr_t aligned = (uintptr_t(bufStart) + 1u) & ~uintptr_t(0x1u);
41+
uint16_t *tmp_row = reinterpret_cast<uint16_t *>(aligned);
3942
SEGENV.step = strip.now;
4043
call++;
4144

0 commit comments

Comments
 (0)