Skip to content

Commit

Permalink
Now builds on avr-gcc 5.4.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil committed Jul 14, 2024
1 parent 9119cc6 commit 19a6fcd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions light_ws2812_AVR/Light_WS2812/light_ws2812.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ void ws2812_sendarray(uint8_t *data,uint16_t datlen)

void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi)
{
// `maskhi` is 0x80 if P?7 is the DATA line to the LED string, 0x04 for P?2 etc.
uint8_t curbyte,ctr,masklo;
uint8_t sreg_prev;
#if __AVR_ARCH__ != 100
Expand All @@ -133,17 +134,30 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi)
ws2812_DDRREG |= maskhi; // Enable output

masklo =~maskhi&ws2812_PORTREG;
// `masklo` becomes the value to write to the PORT? register in order to
// drive the DATA line low.
maskhi |= ws2812_PORTREG;
// `maskhi` becomes the value to write to the PORT? register in order to
// drive the DATA line high. All other bits in the PORT? register are
// preserved by becoming part of the byte that is written here.

sreg_prev=SREG;

// If we are not expected to support interrupts while driving the LED
// string..
#ifdef interrupt_is_disabled
cli();
#endif

// Go through each byte that should be sent to the LED string..
while (datlen--) {
curbyte=*data++;

#ifndef __GNUC__
asm volatile(
#else
__asm__ volatile(
#endif
" ldi %0,8 \n\t"
#ifndef interrupt_is_disabled
" clt \n\t"
Expand Down

0 comments on commit 19a6fcd

Please sign in to comment.