marco valli / TFT_ILI9163C

Dependents:   TFTLCDSCREEN Pong_ILI9163C

Fork of TFT_ILI9163C by _ peu605

Revision:
1:c271e7e2e330
Parent:
0:f90a4405ef98
Child:
2:6c1fadae252f
--- a/TFT_ILI9163C.cpp	Wed Jan 21 14:32:07 2015 +0000
+++ b/TFT_ILI9163C.cpp	Thu Jan 22 12:16:31 2015 +0000
@@ -26,7 +26,8 @@
 
 //Serial pc(SERIAL_TX, SERIAL_RX);
 
-
+// F411RE specific
+#if defined(__F411RE__)
 inline void TFT_ILI9163C::waitSpiFree() {
 	
 	while ((spi_ptr->SR & SPI_SR_TXE) == 0);
@@ -138,6 +139,77 @@
 	_cs = 1;
 }
 
+// mbed general
+#else
+inline void TFT_ILI9163C::waitSpiFree() {
+}
+
+inline void TFT_ILI9163C::writecommand(uint8_t c){
+	
+	_dc = 0;
+	_cs = 0;
+	
+	SPI::write(c);
+
+	_cs = 1;
+}
+
+
+inline void TFT_ILI9163C::writedata(uint8_t c){
+	
+	_dc = 1;
+	_cs = 0;
+	
+	SPI::write(c);
+	
+	_cs = 1;
+} 
+
+
+inline void TFT_ILI9163C::writedata16(uint16_t d){
+	
+	_dc = 1;
+	_cs = 0;
+	
+	SPI::write(d >> 8);
+	SPI::write(d & 0xff);
+	
+	_cs = 1;
+}
+
+
+inline void TFT_ILI9163C::writedata32(uint16_t d1, uint16_t d2){
+	
+	_dc = 1;
+	_cs = 0;
+	
+	SPI::write(d1 >> 8);
+	SPI::write(d1 & 0xff);
+	SPI::write(d2 >> 8);
+	SPI::write(d2 & 0xff);
+
+	_cs = 1;
+}
+
+
+inline void TFT_ILI9163C::writedata16burst(uint16_t d, int32_t len) {
+	
+	if (len < 0) {
+		len = -len;
+	}
+	
+	_dc = 1;
+	_cs = 0;
+	
+	while (len--) {
+		SPI::write(d >> 8);
+		SPI::write(d & 0xff);
+	}
+
+	_cs = 1;
+}
+#endif
+
 
 void TFT_ILI9163C::setBitrate(uint32_t n){
 	SPI::frequency(n);
@@ -149,8 +221,9 @@
 	SPI::format(8,0);			// 8 bit spi mode 0
 	SPI::frequency(5000000L);	// 5MHz
 	
+#if defined(__F411RE__)
 	spi_ptr = (SPI_TypeDef*) _spi.spi;
-	
+
 #if defined(__F411RE_DMA__)
 	hdma.Init.Direction = DMA_MEMORY_TO_PERIPH;
 	hdma.Init.PeriphInc = DMA_PINC_DISABLE;
@@ -191,6 +264,7 @@
 	// set SPI DR ss Peripheral address
 	hdma.Instance->PAR = (uint32_t) &spi_ptr->DR;
 #endif
+#endif
 	
 	if (_resetPinName != NC) {
 		DigitalOut _reset(_resetPinName);