Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.

Dependents:   afero_poc15_180216 afero_poc15_180223 afero_poc15_180302 afero_poc15_180403R ... more

Fork of UniGraphic by GraphicsDisplay

UniGraphic for La Suno Version.
To go with La Suno, WatchDog Reset functions were added in ILI9341.

Committer:
Rhyme
Date:
Mon Dec 25 08:33:03 2017 +0000
Revision:
34:1a148973febe
Parent:
28:2b562717a864
watch dog resets were added in ILI9341

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Geremia 0:75ec1b3cde17 1 #ifndef SPI8_H
Geremia 0:75ec1b3cde17 2 #define SPI8_H
Geremia 0:75ec1b3cde17 3
Geremia 28:2b562717a864 4 #define NDEBUG // avoid MBED_ASSERT to halt process when PinName DC==NC
Geremia 28:2b562717a864 5
Geremia 0:75ec1b3cde17 6 #include "mbed.h"
Geremia 0:75ec1b3cde17 7 #include "Protocols.h"
Geremia 0:75ec1b3cde17 8 //#include "GraphicsDisplay.h"
Geremia 0:75ec1b3cde17 9
Geremia 6:8356d48a07db 10 /** SPI 8bit interface
Geremia 6:8356d48a07db 11 */
Geremia 0:75ec1b3cde17 12 class SPI8 : public Protocols
Geremia 0:75ec1b3cde17 13 {
Geremia 0:75ec1b3cde17 14 public:
Geremia 0:75ec1b3cde17 15
Geremia 0:75ec1b3cde17 16 /** Create an SPI 8bit display interface with 3 control pins
Geremia 0:75ec1b3cde17 17 *
Geremia 0:75ec1b3cde17 18 * @param SPI mosi
Geremia 0:75ec1b3cde17 19 * @param SPI miso
Geremia 0:75ec1b3cde17 20 * @param SPI sclk
Geremia 0:75ec1b3cde17 21 * @param CS pin connected to CS of display
Geremia 0:75ec1b3cde17 22 * @param reset pin connected to RESET of display
Geremia 0:75ec1b3cde17 23 * @param DC pin connected to data/command of display
Geremia 0:75ec1b3cde17 24 */
Geremia 20:14daa48ffd4c 25 SPI8(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC=NC);
Geremia 0:75ec1b3cde17 26
Geremia 0:75ec1b3cde17 27 protected:
Geremia 0:75ec1b3cde17 28
Geremia 1:ff019d22b275 29 /** Send 8bit command to display controller
Geremia 0:75ec1b3cde17 30 *
Geremia 0:75ec1b3cde17 31 * @param cmd: byte to send
Geremia 0:75ec1b3cde17 32 *
Geremia 0:75ec1b3cde17 33 */
Geremia 1:ff019d22b275 34 virtual void wr_cmd8(unsigned char cmd);
Geremia 0:75ec1b3cde17 35
Geremia 1:ff019d22b275 36 /** Send 8bit data to display controller
Geremia 0:75ec1b3cde17 37 *
Geremia 1:ff019d22b275 38 * @param data: byte to send
Geremia 0:75ec1b3cde17 39 *
Geremia 0:75ec1b3cde17 40 */
Geremia 1:ff019d22b275 41 virtual void wr_data8(unsigned char data);
Geremia 0:75ec1b3cde17 42
Geremia 4:12ba0ecc2c1f 43 /** Send 2x8bit command to display controller
Geremia 1:ff019d22b275 44 *
Geremia 1:ff019d22b275 45 * @param cmd: halfword to send
Geremia 1:ff019d22b275 46 */
Geremia 1:ff019d22b275 47 virtual void wr_cmd16(unsigned short cmd);
Geremia 1:ff019d22b275 48
Geremia 4:12ba0ecc2c1f 49 /** Send 2x8bit data to display controller
Geremia 1:ff019d22b275 50 *
Geremia 1:ff019d22b275 51 * @param data: halfword to send
Geremia 1:ff019d22b275 52 *
Geremia 1:ff019d22b275 53 */
Geremia 1:ff019d22b275 54 virtual void wr_data16(unsigned short data);
Geremia 1:ff019d22b275 55
Geremia 4:12ba0ecc2c1f 56 /** Send 16bit pixeldata to display controller
Geremia 4:12ba0ecc2c1f 57 *
Geremia 4:12ba0ecc2c1f 58 * @param data: halfword to send
Geremia 4:12ba0ecc2c1f 59 *
Geremia 4:12ba0ecc2c1f 60 */
Geremia 4:12ba0ecc2c1f 61 virtual void wr_gram(unsigned short data);
Geremia 4:12ba0ecc2c1f 62
Geremia 4:12ba0ecc2c1f 63 /** Send same 16bit pixeldata to display controller multiple times
Geremia 1:ff019d22b275 64 *
Geremia 1:ff019d22b275 65 * @param data: halfword to send
Geremia 1:ff019d22b275 66 * @param count: how many
Geremia 1:ff019d22b275 67 *
Geremia 1:ff019d22b275 68 */
Geremia 4:12ba0ecc2c1f 69 virtual void wr_gram(unsigned short data, unsigned int count);
Geremia 1:ff019d22b275 70
Geremia 4:12ba0ecc2c1f 71 /** Send array of pixeldata shorts to display controller
Geremia 1:ff019d22b275 72 *
Geremia 4:12ba0ecc2c1f 73 * @param data: unsigned short pixeldata array
Geremia 1:ff019d22b275 74 * @param lenght: lenght (in shorts)
Geremia 1:ff019d22b275 75 *
Geremia 1:ff019d22b275 76 */
Geremia 4:12ba0ecc2c1f 77 virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
Geremia 0:75ec1b3cde17 78
Geremia 5:b222a9461d6b 79 /** Read 16bit pixeldata from display controller (with dummy cycle)
Geremia 5:b222a9461d6b 80 *
Geremia 11:b842b8e332cb 81 * @param convert true/false. Convert 18bit to 16bit, some controllers returns 18bit
Geremia 5:b222a9461d6b 82 * @returns 16bit color
Geremia 5:b222a9461d6b 83 */
Geremia 11:b842b8e332cb 84 virtual unsigned short rd_gram(bool convert);
Geremia 5:b222a9461d6b 85
Geremia 7:bb0383b91104 86 /** Read 4x8bit register data (with dummy cycle)
Geremia 7:bb0383b91104 87 * @param reg the register to read
Geremia 7:bb0383b91104 88 * @returns data as uint
Geremia 7:bb0383b91104 89 *
Geremia 7:bb0383b91104 90 */
Geremia 7:bb0383b91104 91 virtual unsigned int rd_reg_data32(unsigned char reg);
Geremia 7:bb0383b91104 92
Geremia 7:bb0383b91104 93 /** Read 3x8bit ExtendedCommands register data
Geremia 7:bb0383b91104 94 * @param reg the register to read
Geremia 7:bb0383b91104 95 * @param SPIreadenablecmd vendor/device specific cmd to read EXTC registers
Geremia 7:bb0383b91104 96 * @returns data as uint
Geremia 7:bb0383b91104 97 * @note EXTC regs (0xB0 to 0xFF) are read/write registers but needs special cmd to be read in SPI mode
Geremia 7:bb0383b91104 98 */
Geremia 7:bb0383b91104 99 virtual unsigned int rd_extcreg_data32(unsigned char reg, unsigned char SPIreadenablecmd);
Geremia 7:bb0383b91104 100
Geremia 20:14daa48ffd4c 101 /** ILI932x specific, does a dummy read cycle, number of bits is protocol dependent
Geremia 20:14daa48ffd4c 102 * for PAR protocols: a signle RD bit toggle
Geremia 20:14daa48ffd4c 103 * for SPI8: 8clocks
Geremia 20:14daa48ffd4c 104 * for SPI16: 16 clocks
Geremia 20:14daa48ffd4c 105 */
Geremia 20:14daa48ffd4c 106 virtual void dummyread ();
Geremia 20:14daa48ffd4c 107
Geremia 20:14daa48ffd4c 108 /** ILI932x specific, select register for a successive write or read
Geremia 20:14daa48ffd4c 109 *
Geremia 20:14daa48ffd4c 110 * @param reg register to be selected
Geremia 20:14daa48ffd4c 111 * @param forread false = a write next (default), true = a read next
Geremia 20:14daa48ffd4c 112 * @note forread only used by SPI protocols
Geremia 20:14daa48ffd4c 113 */
Geremia 20:14daa48ffd4c 114 virtual void reg_select(unsigned char reg, bool forread =false);
Geremia 20:14daa48ffd4c 115
Geremia 20:14daa48ffd4c 116 /** ILI932x specific, write register with data
Geremia 20:14daa48ffd4c 117 *
Geremia 20:14daa48ffd4c 118 * @param reg register to write
Geremia 20:14daa48ffd4c 119 * @param data 16bit data
Geremia 20:14daa48ffd4c 120 */
Geremia 20:14daa48ffd4c 121 virtual void reg_write(unsigned char reg, unsigned short data);
Geremia 20:14daa48ffd4c 122
Geremia 20:14daa48ffd4c 123 /** ILI932x specific, read register
Geremia 20:14daa48ffd4c 124 *
Geremia 20:14daa48ffd4c 125 * @param reg register to be read
Geremia 20:14daa48ffd4c 126 * @returns 16bit register value
Geremia 20:14daa48ffd4c 127 */
Geremia 20:14daa48ffd4c 128 virtual unsigned short reg_read(unsigned char reg);
Geremia 20:14daa48ffd4c 129
Geremia 0:75ec1b3cde17 130 /** HW reset sequence (without display init commands)
Geremia 0:75ec1b3cde17 131 */
Geremia 0:75ec1b3cde17 132 virtual void hw_reset();
Geremia 0:75ec1b3cde17 133
Geremia 0:75ec1b3cde17 134 /** Set ChipSelect high or low
Geremia 0:75ec1b3cde17 135 * @param enable 0/1
Geremia 0:75ec1b3cde17 136 */
Geremia 0:75ec1b3cde17 137 virtual void BusEnable(bool enable);
Geremia 0:75ec1b3cde17 138
Geremia 0:75ec1b3cde17 139 DigitalOut _CS;
Geremia 0:75ec1b3cde17 140
Geremia 0:75ec1b3cde17 141 private:
Geremia 0:75ec1b3cde17 142
Geremia 0:75ec1b3cde17 143 SPI _spi;
Geremia 0:75ec1b3cde17 144 DigitalOut _reset;
Geremia 0:75ec1b3cde17 145 DigitalOut _DC;
Geremia 0:75ec1b3cde17 146
Geremia 0:75ec1b3cde17 147 };
Geremia 0:75ec1b3cde17 148 #endif