adafruit / Adafruit_ILI9341

Library for Adafruit ILI9341 displays
416 stars 283 forks source link

__AVR__ optimizations in spiwrite, spiread don't work on Arduino Uno Wifi #18

Closed cornwarecjp closed 6 years ago

cornwarecjp commented 8 years ago

After some debugging, I found that it started working by disabling the __AVR__ specific code in the spiwrite and spiread functions in Adafruit_ILI9341.cpp. So, in both functions, where the original code says #if defined (__AVR__) my modified code says #if defined (DISABLED) && defined (__AVR__)

With this change, I force that the generic SPI.transfer(..) code is used instead of the __AVR__ specific code in the library. Somehow, that fixed the problem: the graphicstest example works, and the touchpaint example also works, so I assume I now have a completely working touch shield.

I don't know if this problem is specific to my situation, or if other people are going to run into it. In the second case, you might use this report to improve your library. If you know why my system has this problem, please let me know: maybe it could be beneficial to me to use the __AVR__ specific code if there is some way to do that (I assume it's there for some reason - maybe an optimization?).

PS. One final hint on what went wrong: the original library code kept hanging in this loop: while(!(SPSR & _BV(SPIF))); I have no idea why it hangs there, or why the generic SPI library does work.

driverblock commented 8 years ago

I don't know why it's like that. AVR should be using SPI Transfer if it's available. I'll look into it. Thanks for the tip!

ladyada commented 6 years ago

hiya just closing some old open PR's we've updated the library to be based off of Adafruit_SPITFT which abstracts the SPI stuff away. please try it again, if its still being weird, please open another issue!