Skip to content

Added USART SPI for 32u4 Leonardo/Micro #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2015

Conversation

NicoHood
Copy link
Contributor

@NicoHood NicoHood commented Oct 3, 2015

USART SPI gives us the option to use the SPI for other interfaces and still update leds even faster than with bitbang SPI.

A board that optionally breaks out the TX Led pin is required. For example there are some 32u4 breakout boards and the Pololu Mini board which also breaks out all pins.

Note that you should change the TX Led to another pin.
This can be done by editing the variants file. You may use Led 13 as TX indicator Led instead.

Patch for the variants file in Arduino/hardware/arduino/avr/variants/leonardo/pins_arduino.h

#define TX_RX_LED_INIT  DDRC |= (1<<7), DDRB |= (1<<0)
#define TXLED0          PORTC &= ~(1<<7)
#define TXLED1          PORTC |= (1<<7)
#define RXLED0          PORTB |= (1<<0)
#define RXLED1          PORTB &= ~(1<<0)

A more fancy patch can also be created with a custom hardware folder which contains a duplicated, patched pins_arduino.h file.

Add new leds like this:

FastLED.addLeds<CHIPSET,SPI_UART1_DATA, SPI_UART1_CLOCK, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(CORRECTION);

Since pin 24 wont't work for attaching anyways we can still enable Hardware USART SPI for those users who understand what they are doing (or pretend to) without patching FastLED on every update.

All code was tested with a Pololu Mini LV board, the patches above and 25 WS2801 leds. Got an FPS gain of 100%.

Note that you should change the TX Led to another pin.
This can be done by editing the variants file. You may use Led 13 as TX indicator Led instead.
focalintent added a commit that referenced this pull request Oct 3, 2015
Added USART SPI for 32u4 Leonardo/Micro
@focalintent focalintent merged commit e747e4f into FastLED:master Oct 3, 2015
NicoHood added a commit to NicoHood/FastLED that referenced this pull request Nov 24, 2015
After arduino/Arduino#3680 got merged, TX Led got officially supported.
This means, we have to move the number upwards from 24 ( FastLED#214 ).
The padding pins are the A6 - A11 definitions, which should now work as well.
@NicoHood NicoHood deleted the leonardoUSARTSPI branch December 19, 2015 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants