cpldcpu / light_ws2812

Light weight library to control WS2811/WS2812 based LEDS and LED Strings for 8-Bit AVR microcontrollers.
GNU General Public License v3.0
946 stars 207 forks source link

Now builds on avr-gcc 5.4.0. #106

Closed un-clouded closed 2 months ago

un-clouded commented 2 months ago

Hi Tim,

I had to replace asm volatile with __asm__ volatile to get it to build on avr-gcc. I did also add a few comments as I was trying to understand the code better. Please let me know if you want to separate the changes if you want one but not the other.

Cheers!

cpldcpu commented 2 months ago

Hi, I am a bit confused why this is necessary. I am also using AVR-GCC 5.4. and I can compile the code as is?

gcc version 5.4.0 (AVR_8_bit_GNU_Toolchain_3.6.2_1778)

Which version of gcc are you using specifically?

un-clouded commented 2 months ago

Whoops, OK. The package is gcc-avr version 1:5.4.0+Atmel3.6.2-3. Perhaps I am using different compiler options? It's a hand-rolled Makefile and the compiler invocation is:

avr-gcc -fdata-sections -ffunction-sections -std=c99 -mmcu=atmega48 -Os -fshort-enums -DF_CPU=16000000 -DBAUD=9600 -Wall   -c light_ws2812.c -o light_ws2812.o

If I try to compile without changing asm to __asm__ I get:

light_ws2812.c: In function ‘ws2812_sendarray_mask’:
light_ws2812.c:160:5: error: ‘asm’ undeclared (first use in this function)
     asm volatile(
     ^
light_ws2812.c:160:5: note: each undeclared identifier is reported only once for each function it appears in
light_ws2812.c:160:9: error: expected ‘;’ before ‘volatile’
     asm volatile(
         ^
cpldcpu commented 2 months ago

can you try building the examples with the supplied makefile?

Edit: -std=c99 seems to be the reason.

cpldcpu commented 2 months ago

https://stackoverflow.com/questions/755457/asm-in-c-gives-an-error-with-std-c99

cpldcpu commented 2 months ago

Can you update the pull request to address the comments? I will merge then. Thank you for your help :)

un-clouded commented 2 months ago

Sure. Should I remove the code comments completely, or trim them down?

Thanks heaps for all the work. It's a delight to be able to choose AVR rather than Arduino.

cpldcpu commented 2 months ago

Merged, thanks a lot!