0

Porting library to MSP430
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Porting library to MSP430

by waikei33 on Sun Apr 16, 2017 6:04 pm

Hi. I just bought the Adafruit 1.44" Color TFT LCD Display which needs both the Adafruit GFX Graphics Library and the Adafruit_ST7735 Library. These two are written for Arduino though the website says they can be rewritten for other microcontroller. I am trying to use them for MSP430G2553. Can someone give me instructions on how to rewrite the libraries to adapt to MSP430? Thank you so much!

waikei33
 
Posts: 2
Joined: Sun Apr 16, 2017 5:51 pm

Re: Porting library to MSP430

by adafruit_support_rick on Mon Apr 17, 2017 9:44 am

The libraries are written in C++, so that part should move over to C++ on your MSP430 pretty easily.
The ST7735 library will have some dependencies on the Arduino runtime for SPI and GPIO pin mapping. You will have to change those dependencies to something from the MSP430 runtime.

Adafruit_GFX subclasses the Arduino Print class, which does conversions of binary data to strings, serial output, etc. You will need to come up with your own Print class to provide those functions. You will also see some references to "pgmspace", which is a feature of Atmel AVR hardware. References can be replaced with macros like these:
Code: Select all | TOGGLE FULL SIZE
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))


The AVR is a "Harvard" architecture, which has separate data and program memory spaces. the pgmspace functions transfer data from program space to data space.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Porting library to MSP430

by waikei33 on Tue Apr 18, 2017 3:46 am

adafruit_support_rick wrote:The libraries are written in C++, so that part should move over to C++ on your MSP430 pretty easily.
The ST7735 library will have some dependencies on the Arduino runtime for SPI and GPIO pin mapping. You will have to change those dependencies to something from the MSP430 runtime.

Adafruit_GFX subclasses the Arduino Print class, which does conversions of binary data to strings, serial output, etc. You will need to come up with your own Print class to provide those functions. You will also see some references to "pgmspace", which is a feature of Atmel AVR hardware. References can be replaced with macros like these:
Code: Select all | TOGGLE FULL SIZE
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))


The AVR is a "Harvard" architecture, which has separate data and program memory spaces. the pgmspace functions transfer data from program space to data space.



Hi Rick thank you for your reply! I am kind of a beginner in the area and I am complete unfamiliar with the Arduino. Should I make all the changes in the .cpp file? In the ST7735 library, I am not sure where I should modify the pinmapping; in the GTX library, what reference should I replace pgmspace with? I know this is quite complicated but I really appreciate your help.

waikei33
 
Posts: 2
Joined: Sun Apr 16, 2017 5:51 pm

Re: Porting library to MSP430

by adafruit_support_rick on Tue Apr 18, 2017 11:03 am

You should familiarize yourself with the Arduino runtime library, so you know what everything is supposed to do:
https://www.arduino.cc/en/Reference/HomePage

You will make your changes to the .h and .cpp files in both libraries. The pin mapping depends on how the MSP430 does GPIO. I don't know. I think you will just want to eliminate references to pgmspace, but you will need to use the macros I posted in those places where program space is read.

To do this, you will need to have a good knowledge of how the MSP430 operates.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Porting library to MSP430

by DerekSpeegle on Mon Sep 09, 2019 6:57 pm

Hello,

I'm having this issue as well. I've been using the Adafruit GFX library in energia with no problem but it appears that the new one wont compile and I cant seem to figure out why. It gives me errors such as this:
Code: Select all | TOGGLE FULL SIZE
energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:476:32: error: ISO C++ forbids in-class initialization of non-const static member 'wide'

I am currently trying to modify the ST7735 library to work with energia and msp430 but I'm having an extremely hard time getting it to compile. Changing the pinouts and such is easy, but figuring out what why it wont compile is confusing. Is there anyone who is familiar with the msp430 and energia that can please help port these two libraries over? I imagine it's fairly straight forward but there something I'm missing here. Here is what I'm currently looking at when i attempt to compile an example. Please help.

Thanks,



Code: Select all | TOGGLE FULL SIZE
WARNING: Spurious .github folder in 'Adafruit SSD1306' library
WARNING: Spurious .github folder in 'Adafruit ST7735 and ST7789 Library' library
In file included from C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_ST7735/Adafruit_ST77xx.h:31:0,

                 from C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_ST7735/Adafruit_ST7735.h:4,

                 from C:\Users\Derek\AppData\Local\Temp\arduino_modified_sketch_870601\displayOnOffTest.ino:15:

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:476:32: error: ISO C++ forbids initialization of member 'wide' [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:476:32: error: making 'wide' static [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:476:32: error: ISO C++ forbids in-class initialization of non-const static member 'wide'

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:509:31: error: ISO C++ forbids initialization of member '_xstart' [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:509:31: error: making '_xstart' static [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:509:31: error: ISO C++ forbids in-class initialization of non-const static member '_xstart'

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:510:31: error: ISO C++ forbids initialization of member '_ystart' [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:510:31: error: making '_ystart' static [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:510:31: error: ISO C++ forbids in-class initialization of non-const static member '_ystart'

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:511:38: error: ISO C++ forbids initialization of member 'invertOnCommand' [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:511:38: error: making 'invertOnCommand' static [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:511:38: error: ISO C++ forbids in-class initialization of non-const static member 'invertOnCommand'

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:512:38: error: ISO C++ forbids initialization of member 'invertOffCommand' [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:512:38: error: making 'invertOffCommand' static [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:512:38: error: ISO C++ forbids in-class initialization of non-const static member 'invertOffCommand'

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:514:27: error: ISO C++ forbids initialization of member '_freq' [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:514:27: error: making '_freq' static [-fpermissive]

C:\Users\Derek\Desktop\energia-1.6.10E18\libraries\Adafruit_GFX/Adafruit_SPITFT.h:514:27: error: ISO C++ forbids in-class initialization of non-const static member '_freq'

exit status 1
Error compiling for board MSP-EXP430FR5994LP.

DerekSpeegle
 
Posts: 5
Joined: Thu Feb 04, 2016 3:16 pm

Please be positive and constructive with your questions and comments.