ILI9340 Library based on the Arduino version from Adafruit. It has been tested with a custom STM32F103C8 board.

Porting of the ILI9340 Library from Adafruit. It has been tested on a custom board based on a STM32F103C8 microcontroller.

Please, see the Wiki page on how to use the library

Revision:
1:5f8309157018
Parent:
0:0bf2453a67ba
--- a/Adafruit_ILI9340.cpp	Tue Nov 04 08:08:46 2014 +0000
+++ b/Adafruit_ILI9340.cpp	Wed Nov 05 13:41:43 2014 +0000
@@ -23,8 +23,8 @@
 #include "stdint.h"
 
 
-#define SET_BIT(dpin) dpin->write(1)
-#define CLEAR_BIT(dpin) dpin->write(0)
+#define OSET_BIT(dpin) dpin->write(1)
+#define OCLEAR_BIT(dpin) dpin->write(0)
 
 #define digitalWrite(dpin,value) ((value==0)?dpin->write(0):dpin->write(1))
 #define digitalRead(dpin) (dpin->read())
@@ -74,43 +74,43 @@
     // Fast SPI bitbang swiped from LPD8806 library
     for(uint8_t bit = 0x80; bit; bit >>= 1) {
       if(c & bit) {        
-        SET_BIT(mosiport);
+        OSET_BIT(mosiport);
       } else {
         
-        CLEAR_BIT(mosiport);
+        OCLEAR_BIT(mosiport);
       }      
-      SET_BIT(clkport);      
-      CLEAR_BIT(clkport);
+      OSET_BIT(clkport);      
+      OCLEAR_BIT(clkport);
     }
   }
 }
 
 
 void Adafruit_ILI9340::writecommand(uint8_t c) {
-  CLEAR_BIT(dcport);
+  OCLEAR_BIT(dcport);
 	if (!hwSPI)
-		CLEAR_BIT(clkport);
+		OCLEAR_BIT(clkport);
 
-  CLEAR_BIT(csport);
+  OCLEAR_BIT(csport);
 
   spiwrite(c);
 
-  SET_BIT(csport);
+  OSET_BIT(csport);
 }
 
 
 void Adafruit_ILI9340::writedata(uint8_t c) {
-  SET_BIT(dcport);
+  OSET_BIT(dcport);
 	if (!hwSPI)
-		CLEAR_BIT(clkport);
+		OCLEAR_BIT(clkport);
 
-  CLEAR_BIT(csport);
+  OCLEAR_BIT(csport);
   
   
   spiwrite(c);
 
 
-  SET_BIT(csport);
+  OSET_BIT(csport);
 } 
 
 // Rather than a bazillion writecommand() and writedata() calls, screen
@@ -152,8 +152,8 @@
   if(hwSPI) {  
   	hwSPI->frequency(16000000);
   } else {
-    CLEAR_BIT(clkport);
-    CLEAR_BIT(mosiport);
+    OCLEAR_BIT(clkport);
+    OCLEAR_BIT(mosiport);
   }
   // toggle RST low to reset
 
@@ -309,14 +309,14 @@
 
 void Adafruit_ILI9340::pushColor(uint16_t color) {
   
-  SET_BIT(dcport);
+  OSET_BIT(dcport);
   
-  CLEAR_BIT(csport);
+  OCLEAR_BIT(csport);
 
   spiwrite(color >> 8);
   spiwrite(color);
 
-  SET_BIT(csport);
+  OSET_BIT(csport);
   
 }
 
@@ -327,14 +327,14 @@
   setAddrWindow(x,y,x+1,y+1);
 
   
-  SET_BIT(dcport);
+  OSET_BIT(dcport);
   
-  CLEAR_BIT(csport);
+  OCLEAR_BIT(csport);
 
   spiwrite(color >> 8);
   spiwrite(color);
 
-  SET_BIT(csport);
+  OSET_BIT(csport);
   
 }
 
@@ -352,16 +352,16 @@
 
   uint8_t hi = color >> 8, lo = color;
 
-  SET_BIT(dcport);
+  OSET_BIT(dcport);
   
-  CLEAR_BIT(csport);
+  OCLEAR_BIT(csport);
   
 
   while (h--) {
     spiwrite(hi);
     spiwrite(lo);
   }
-  SET_BIT(csport);
+  OSET_BIT(csport);
   
 }
 
@@ -375,14 +375,14 @@
   setAddrWindow(x, y, x+w-1, y);
 
   uint8_t hi = color >> 8, lo = color;
-  SET_BIT(dcport);
-  CLEAR_BIT(csport);
+  OSET_BIT(dcport);
+  OCLEAR_BIT(csport);
 
   while (w--) {
     spiwrite(hi);
     spiwrite(lo);
   }
-  SET_BIT(csport);
+  OSET_BIT(csport);
 
 }
 
@@ -403,9 +403,9 @@
 
   uint8_t hi = color >> 8, lo = color;
 
-  SET_BIT(dcport);
+  OSET_BIT(dcport);
   //digitalWrite(_dc, HIGH);
-  CLEAR_BIT(csport);
+  OCLEAR_BIT(csport);
   //digitalWrite(_cs, LOW);
 
   for(y=h; y>0; y--) {
@@ -415,7 +415,7 @@
     }
   }
   //digitalWrite(_cs, HIGH);
-  SET_BIT(csport);
+  OSET_BIT(csport);
 }