energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
798 stars 670 forks source link

All MCUs: Update SPI Library #1003

Open rei-vilo opened 6 years ago

rei-vilo commented 6 years ago

Current Energia SPI library still relies on the old SPI library implementation, with setClockDivider().

For example, for SPI setClockDivider(), Arduino warns to use SPISettings with SPI.beginTransaction() instead.

This function should not be used in new projects. Use SPISettings with SPI.beginTransaction() to configure SPI parameters.

As an additional benefit, SPISettings allows to specify the speed directly in Hz and no longer as a divider.

SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0));

This greatly enhances portability across different MCUs, and ensures a better compatibility with Arduino framework.

rei-vilo commented 6 years ago

The most important part of this ticket is to allow faster speeds. Today, maximum speed tops at 16 MHz. More powerful MCUs and compatible SPI devices run at faster SPI speeds.

rei-vilo commented 6 years ago

MSP430 already has SPI.beginTransaction() and SPISettings implemented.

https://github.com/energia/msp430-lg-core/blob/ce7b0a8a44ad49a4ef2a2ee8a9bdcb9878859c9d/libraries/SPI/SPI.h#L70