Jump to content
43oh

[Energia Library] SPI fork - 9-bit support


Recommended Posts

I've extended the Energia SPI library to support 9-bit SPI on all MSP430-based platforms.  Tested on G2452 and G2553 so far, I don't have a FRaunchpad so I can't test it there at the moment.  I trust that it should work based on a code comparison with the G2553 USCI implementation though.

 

SPI class contains the .transfer9() function which takes & returns an unsigned 16-bit integer containing a right-shifted 9-bit value.

 

The 9th bit is implemented natively on USI platforms (with appropriate shifting sensitive to MSB-first vs LSB-first operation of the USISR 16-bit register) but it uses a custom software bit-bang approach for the 9th bit on USCI platforms.  The code to implement this is a bit ugly but knock on wood, it seems to work.  Supports all 4 SPI clock phase/polarity modes too.

 

The purpose behind this modification is to support LCD displays that require 9-bit SPI, as many do when they are configured to forego the use of a dedicated Data/Control line in lieu of the 8th bit of each SPI packet indicating D/C.  This effort was taken to support the Nokia 1202 LCD display, available cheap online from chinese vendors (~$1.50/pc for a 96x68 pixel B&W LED-backlit display with DIY solderable 0.6mm pitch SMD connector) but happens to include an STE2007 controller wired for 9-bit SPI operation.

 

Github site: https://github.com/spirilis/SPI

Release tested on G2553 and G2452: SPI_9bit.zip

 

This should unzip a "SPI" directory which you may place in your home profile's libraries/ subdir, e.g. ~/Documents/Energia/libraries on the Mac.  Energia should preferentially use this version over its own app-installed version for all future SPI calls.  No modifications were made to the normal 8-bit SPI implementation.

Link to post
Share on other sites
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...