Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SPI_TFT_ILI9341 by
Revision 12:ab5e34c9f3f9, committed 2014-09-04
- Comitter:
- Geremia
- Date:
- Thu Sep 04 22:54:09 2014 +0000
- Parent:
- 11:365aa15eaa0f
- Commit message:
- always 16bit spi for speedup on slower cpu, added read id, read status, read pixel, other stuff i can't remember
Changed in this revision
SPI_TFT_ILI9341.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SPI_TFT_ILI9341.cpp Thu Sep 04 22:17:14 2014 +0000 +++ b/SPI_TFT_ILI9341.cpp Thu Sep 04 22:54:09 2014 +0000 @@ -15,6 +15,9 @@ // 18.10.13 Better Circle function from Michael Ammann // 22.10.13 Fixes for Kinetis Board - 8 bit spi // 26.01.14 Change interface for BMP_16 to also use SD-cards +// 01-09-14 Geremia: +// using always 16bit spi. Now 8bits are wasted every cmd, but slower cpus takes more time to send 3x8bits than 2x16bits with 8bit wasted +// added read stuff, like read ID, read status, read pixel #include "SPI_TFT_ILI9341.h" #include "mbed.h" @@ -23,9 +26,6 @@ // if display is the only slave into the SPI bus, we can skip driving CS at every cmd //#define USE_CS - -//extern Serial pc; -//extern DigitalOut xx; // debug !! SPI_TFT_ILI9341::SPI_TFT_ILI9341(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset, PinName dc, const char *name) : _spi(mosi, miso, sclk), _cs(cs), _reset(reset), _dc(dc), GraphicsDisplay(name) @@ -93,7 +93,7 @@ void SPI_TFT_ILI9341::wr_8(unsigned char value) { _spi.format(8,0); // changing format takes time but wr_8 is used only for init and set orientation - _spi.write(value); // mbed lib + _spi.write(value); _spi.format(16,0); } @@ -113,7 +113,7 @@ _cs = 0; #endif _spi.write(cmd); // mbed lib - _dc = 1; // fixed + // _dc = 1; //not needed for read cmds r = _spi.write(0) >> 8; #ifdef USE_CS _cs = 1; @@ -130,7 +130,7 @@ _cs = 0; #endif _spi.write(cmd); - _dc = 1; +// _dc = 1; //not needed for read cmds r = _spi.write(0); // we get only 15bit valid, first bit was the dummy cycle d = r; r = _spi.write(0); @@ -153,7 +153,7 @@ _cs = 0; #endif _spi.write(cmd); - _dc = 1; + // _dc = 1; //not needed for read cmds r = _spi.write(0); // we get only 15bit valid, first bit was the dummy cycle d = r; r = _spi.write(0); @@ -167,7 +167,7 @@ #endif return(d); } -// for read cmds that needs a dummy byte (not a dummy bit, like 2E ram read) +// for read cmds that needs a dummy byte (not a dummy bit) like 2E ram read unsigned int SPI_TFT_ILI9341::wr_cmd_rd32_dbyte(unsigned char cmd) { unsigned int r; @@ -175,8 +175,8 @@ #ifdef USE_CS _cs = 0; #endif - _spi.write(cmd<<8); // send cmd then 00byte, cmd is processed and second byte is the dummy byte - _dc = 1; //not needed for read cmds + _spi.write(cmd<<8); // send cmd then 00, cmd is processed immediatly, so the second byte will be the dummy byte + // _dc = 1; //not needed for read cmds r = _spi.write(0)<<16; // Byte3,2 r = r | _spi.write(0); // Byte1,0 // now need to reset because some cmds would expect to xfer more data