Permalink
Browse files

Modified the library to work with MSP430

  • Loading branch information...
alkhimey committed Apr 29, 2016
1 parent b7fbe58 commit d232e057a852b474b509c42bb5a237d2f1905538
Showing with 39 additions and 4 deletions.
  1. +11 −2 Adafruit_ILI9341.cpp
  2. +4 −0 Adafruit_ILI9341.h
  3. +24 −2 examples/graphicstest/graphicstest.ino
@@ -20,7 +20,11 @@
#include <pgmspace.h>
#endif
#include <limits.h>
#ifdef ENERGIA
#include "pins_energia.h"
#else
#include "pins_arduino.h"
#endif
#include "wiring_private.h"
#include <SPI.h>
@@ -91,7 +95,7 @@ void Adafruit_ILI9341::spiwrite(uint8_t c) {
SPI.transfer(c);
#endif
} else {
#if defined(ESP8266) || defined (ARDUINO_ARCH_ARC32)
#if defined(ESP8266) || defined(MSP430) || defined (ARDUINO_ARCH_ARC32)
for(uint8_t bit = 0x80; bit; bit >>= 1) {
if(c & bit) {
digitalWrite(_mosi, HIGH);
@@ -216,13 +220,18 @@ void Adafruit_ILI9341::begin(void) {
#ifndef SPI_HAS_TRANSACTION
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
#if defined (_AVR__)
SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!)
mySPCR = SPCR;
#elif defined(TEENSYDUINO)
SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!)
#elif defined (__arm__)
SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
#elif defined(MSP430)
SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz assuming 16Mhz board is chosen
#endif
#endif
} else {
@@ -307,7 +316,7 @@ void Adafruit_ILI9341::begin(void) {
writedata(0x10); //SAP[2:0];BT[3:0]
writecommand(ILI9341_VMCTR1); //VCM control
writedata(0x3e); //¶Ô±È¶Èµ÷½Ú
writedata(0x3e);
writedata(0x28);
writecommand(ILI9341_VMCTR2); //VCM control2
@@ -175,6 +175,10 @@ class Adafruit_ILI9341 : public Adafruit_GFX {
int8_t _cs, _dc, _rst, _mosi, _miso, _sclk;
#elif defined (ESP8266)
int32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
#elif defined (MSP430)
uint8_t _cs, _dc, _rst, _mosi, _miso, _sclk;
#else
#error Adafruit ILI9341 library: The target you are compiling for is not one of the supported trgets
#endif
};
@@ -18,13 +18,29 @@
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#ifdef ENERGIA
void yield() {}
#endif
// For the Adafruit shield, these are the default.
#ifdef MSP430
#define TFT_DC P2_1
#define TFT_CS P2_2
#else
#define TFT_DC 9
#define TFT_CS 10
#endif
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// If using the breakout, change pins as desired
#ifdef MSP430 // Beware, software SPI is too slow
//#define TFT_MOSI P1_7
//#define TFT_CLK P1_5
//#define TFT_MISO P1_6
//#define TFT_RST 0 // None
#endif
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
void setup() {
@@ -123,6 +139,11 @@ unsigned long testFillScreen() {
}
unsigned long testText() {
#if defined(__MSP430G2553) // MSP430G2553 does not have enough ROM, so sketch size needs to be reduced
// Notice that 2231 and 22452 has even lower ROM sizes, one will need to
// reduce sketch size further.
#warning Compiling without testText to reduce sketch size below 16kb
#else
tft.fillScreen(ILI9341_BLACK);
unsigned long start = micros();
tft.setCursor(0, 0);
@@ -147,6 +168,7 @@ unsigned long testText() {
tft.println("with my blurglecruncheon,");
tft.println("see if I don't!");
return micros() - start;
#endif
}
unsigned long testLines(uint16_t color) {
@@ -362,4 +384,4 @@ unsigned long testFilledRoundRects() {
}
return micros() - start;
}
}

0 comments on commit d232e05

Please sign in to comment.