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.
Protocols/Protocols.h@1:ff019d22b275, 2015-02-13 (annotated)
- Committer:
- Geremia
- Date:
- Fri Feb 13 15:25:10 2015 +0000
- Revision:
- 1:ff019d22b275
- Parent:
- 0:75ec1b3cde17
- Child:
- 3:48f3282c2be8
Added SPI_16, LCD done
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Geremia | 0:75ec1b3cde17 | 1 | /** @file Protocols.h |
Geremia | 0:75ec1b3cde17 | 2 | */ |
Geremia | 0:75ec1b3cde17 | 3 | #ifndef Protocols_H |
Geremia | 0:75ec1b3cde17 | 4 | #define Protocols_H |
Geremia | 0:75ec1b3cde17 | 5 | |
Geremia | 0:75ec1b3cde17 | 6 | #include "mbed.h" |
Geremia | 0:75ec1b3cde17 | 7 | |
Geremia | 0:75ec1b3cde17 | 8 | /** Protocol types |
Geremia | 0:75ec1b3cde17 | 9 | */ |
Geremia | 0:75ec1b3cde17 | 10 | enum proto_t { |
Geremia | 0:75ec1b3cde17 | 11 | PAR_8 /**< Parallel 8bit, pins 0 to 7 */ |
Geremia | 0:75ec1b3cde17 | 12 | ,PAR_16 /**< Parallel 16bit, pins 0 to 15 */ |
Geremia | 0:75ec1b3cde17 | 13 | ,SPI_8 /**< SPI 8bit */ |
Geremia | 0:75ec1b3cde17 | 14 | ,SPI_16 /**< SPI 16bit */ |
Geremia | 0:75ec1b3cde17 | 15 | }; |
Geremia | 0:75ec1b3cde17 | 16 | |
Geremia | 0:75ec1b3cde17 | 17 | |
Geremia | 0:75ec1b3cde17 | 18 | /** Abstract class for spi and parallel protocols |
Geremia | 0:75ec1b3cde17 | 19 | */ |
Geremia | 0:75ec1b3cde17 | 20 | class Protocols |
Geremia | 0:75ec1b3cde17 | 21 | { |
Geremia | 0:75ec1b3cde17 | 22 | public: |
Geremia | 0:75ec1b3cde17 | 23 | |
Geremia | 1:ff019d22b275 | 24 | /** Send 8bit command to display controller |
Geremia | 0:75ec1b3cde17 | 25 | * |
Geremia | 0:75ec1b3cde17 | 26 | * @param cmd: byte to send |
Geremia | 0:75ec1b3cde17 | 27 | * |
Geremia | 0:75ec1b3cde17 | 28 | */ |
Geremia | 1:ff019d22b275 | 29 | virtual void wr_cmd8(unsigned char cmd) = 0; |
Geremia | 0:75ec1b3cde17 | 30 | |
Geremia | 1:ff019d22b275 | 31 | /** Send 8bit data to display controller |
Geremia | 0:75ec1b3cde17 | 32 | * |
Geremia | 1:ff019d22b275 | 33 | * @param data: byte to send |
Geremia | 0:75ec1b3cde17 | 34 | * |
Geremia | 0:75ec1b3cde17 | 35 | */ |
Geremia | 1:ff019d22b275 | 36 | virtual void wr_data8(unsigned char data) = 0; |
Geremia | 0:75ec1b3cde17 | 37 | |
Geremia | 1:ff019d22b275 | 38 | /** Send same 8bit data to display controller multiple times |
Geremia | 0:75ec1b3cde17 | 39 | * |
Geremia | 1:ff019d22b275 | 40 | * @param data: byte to send |
Geremia | 0:75ec1b3cde17 | 41 | * @param count: how many |
Geremia | 0:75ec1b3cde17 | 42 | * |
Geremia | 0:75ec1b3cde17 | 43 | */ |
Geremia | 1:ff019d22b275 | 44 | virtual void wr_data8(unsigned char data, unsigned int count) = 0; |
Geremia | 0:75ec1b3cde17 | 45 | |
Geremia | 0:75ec1b3cde17 | 46 | /** Send array of data bytes to display controller |
Geremia | 0:75ec1b3cde17 | 47 | * |
Geremia | 1:ff019d22b275 | 48 | * @param data: unsigned char data array |
Geremia | 1:ff019d22b275 | 49 | * @param lenght: lenght |
Geremia | 1:ff019d22b275 | 50 | * |
Geremia | 1:ff019d22b275 | 51 | */ |
Geremia | 1:ff019d22b275 | 52 | virtual void wr_data8buf(unsigned char* data, unsigned int lenght) = 0; |
Geremia | 1:ff019d22b275 | 53 | |
Geremia | 1:ff019d22b275 | 54 | /** Send 16bit command to display controller |
Geremia | 1:ff019d22b275 | 55 | * |
Geremia | 1:ff019d22b275 | 56 | * @param cmd: halfword to send |
Geremia | 1:ff019d22b275 | 57 | * |
Geremia | 1:ff019d22b275 | 58 | */ |
Geremia | 1:ff019d22b275 | 59 | virtual void wr_cmd16(unsigned short cmd) = 0; |
Geremia | 1:ff019d22b275 | 60 | |
Geremia | 1:ff019d22b275 | 61 | /** Send 16bit data to display controller |
Geremia | 1:ff019d22b275 | 62 | * |
Geremia | 1:ff019d22b275 | 63 | * @param data: halfword to send |
Geremia | 0:75ec1b3cde17 | 64 | * |
Geremia | 0:75ec1b3cde17 | 65 | */ |
Geremia | 1:ff019d22b275 | 66 | virtual void wr_data16(unsigned short data) = 0; |
Geremia | 1:ff019d22b275 | 67 | |
Geremia | 1:ff019d22b275 | 68 | /** Send same 16bit data to display controller multiple times |
Geremia | 1:ff019d22b275 | 69 | * |
Geremia | 1:ff019d22b275 | 70 | * @param data: halfword to send |
Geremia | 1:ff019d22b275 | 71 | * @param count: how many |
Geremia | 1:ff019d22b275 | 72 | * |
Geremia | 1:ff019d22b275 | 73 | */ |
Geremia | 1:ff019d22b275 | 74 | virtual void wr_data16(unsigned short data, unsigned int count) = 0; |
Geremia | 1:ff019d22b275 | 75 | |
Geremia | 1:ff019d22b275 | 76 | /** Send array of data shorts to display controller |
Geremia | 1:ff019d22b275 | 77 | * |
Geremia | 1:ff019d22b275 | 78 | * @param data: unsigned short data array |
Geremia | 1:ff019d22b275 | 79 | * @param lenght: lenght (in shorts) |
Geremia | 1:ff019d22b275 | 80 | * |
Geremia | 1:ff019d22b275 | 81 | */ |
Geremia | 1:ff019d22b275 | 82 | virtual void wr_data16buf(unsigned short* data, unsigned int lenght) = 0; |
Geremia | 0:75ec1b3cde17 | 83 | |
Geremia | 0:75ec1b3cde17 | 84 | /** HW reset sequence (without display init commands) |
Geremia | 0:75ec1b3cde17 | 85 | */ |
Geremia | 0:75ec1b3cde17 | 86 | virtual void hw_reset() = 0; |
Geremia | 0:75ec1b3cde17 | 87 | |
Geremia | 0:75ec1b3cde17 | 88 | /** Set ChipSelect high or low |
Geremia | 0:75ec1b3cde17 | 89 | * @param enable 0/1 |
Geremia | 0:75ec1b3cde17 | 90 | */ |
Geremia | 0:75ec1b3cde17 | 91 | virtual void BusEnable(bool enable) = 0; |
Geremia | 0:75ec1b3cde17 | 92 | |
Geremia | 0:75ec1b3cde17 | 93 | }; |
Geremia | 0:75ec1b3cde17 | 94 | #endif |