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
UniGraphic for La Suno Version.
To go with La Suno, WatchDog Reset functions were added in ILI9341.
Protocols/PAR8.cpp@0:75ec1b3cde17, 2015-02-12 (annotated)
- Committer:
- Geremia
- Date:
- Thu Feb 12 22:22:47 2015 +0000
- Revision:
- 0:75ec1b3cde17
- Child:
- 1:ff019d22b275
Initial tests, LCD par and spi ok
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Geremia | 0:75ec1b3cde17 | 1 | #include "PAR8.h" |
Geremia | 0:75ec1b3cde17 | 2 | |
Geremia | 0:75ec1b3cde17 | 3 | PAR8::PAR8(PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD) |
Geremia | 0:75ec1b3cde17 | 4 | : _port(port,0xFF), _CS(CS), _reset(reset), _DC(DC), _WR(WR), _RD(RD) |
Geremia | 0:75ec1b3cde17 | 5 | { |
Geremia | 0:75ec1b3cde17 | 6 | _reset = 1; |
Geremia | 0:75ec1b3cde17 | 7 | _DC=1; |
Geremia | 0:75ec1b3cde17 | 8 | _WR=1; |
Geremia | 0:75ec1b3cde17 | 9 | _RD=1; |
Geremia | 0:75ec1b3cde17 | 10 | _CS=1; |
Geremia | 0:75ec1b3cde17 | 11 | #ifdef STMPORTDEBUG |
Geremia | 0:75ec1b3cde17 | 12 | findport(port); //on return, GPIO get disabled |
Geremia | 0:75ec1b3cde17 | 13 | #endif |
Geremia | 0:75ec1b3cde17 | 14 | _port.mode(PullNone); |
Geremia | 0:75ec1b3cde17 | 15 | _port.output(); // will re-enable our GPIO port |
Geremia | 0:75ec1b3cde17 | 16 | hw_reset(); |
Geremia | 0:75ec1b3cde17 | 17 | } |
Geremia | 0:75ec1b3cde17 | 18 | |
Geremia | 0:75ec1b3cde17 | 19 | #ifdef STMPORTDEBUG |
Geremia | 0:75ec1b3cde17 | 20 | // create a port obj with STM HAL drivers, just to collect memorymapped regs |
Geremia | 0:75ec1b3cde17 | 21 | void PAR8::findport(PortName port) |
Geremia | 0:75ec1b3cde17 | 22 | { |
Geremia | 0:75ec1b3cde17 | 23 | port_t tempport; |
Geremia | 0:75ec1b3cde17 | 24 | port_init(&tempport, port, 0xFF, PIN_INPUT); |
Geremia | 0:75ec1b3cde17 | 25 | outreg = tempport.reg_out; |
Geremia | 0:75ec1b3cde17 | 26 | inreg = tempport.reg_in; |
Geremia | 0:75ec1b3cde17 | 27 | // debug("out 0x%.8X in 0x%.8X\r\n", outreg, inreg); |
Geremia | 0:75ec1b3cde17 | 28 | } |
Geremia | 0:75ec1b3cde17 | 29 | #endif |
Geremia | 0:75ec1b3cde17 | 30 | void PAR8::wr_cmd(unsigned char cmd) |
Geremia | 0:75ec1b3cde17 | 31 | { |
Geremia | 0:75ec1b3cde17 | 32 | #ifdef USE_CS |
Geremia | 0:75ec1b3cde17 | 33 | _CS = 0; |
Geremia | 0:75ec1b3cde17 | 34 | #endif |
Geremia | 0:75ec1b3cde17 | 35 | _DC = 0; // 0=cmd |
Geremia | 0:75ec1b3cde17 | 36 | _WR=0; |
Geremia | 0:75ec1b3cde17 | 37 | _port.write(cmd); // write 8bit |
Geremia | 0:75ec1b3cde17 | 38 | _WR=1; |
Geremia | 0:75ec1b3cde17 | 39 | #ifdef USE_CS |
Geremia | 0:75ec1b3cde17 | 40 | _CS = 1; |
Geremia | 0:75ec1b3cde17 | 41 | #endif |
Geremia | 0:75ec1b3cde17 | 42 | } |
Geremia | 0:75ec1b3cde17 | 43 | void PAR8::wr_data8(unsigned char data8) |
Geremia | 0:75ec1b3cde17 | 44 | { |
Geremia | 0:75ec1b3cde17 | 45 | #ifdef USE_CS |
Geremia | 0:75ec1b3cde17 | 46 | _CS = 0; |
Geremia | 0:75ec1b3cde17 | 47 | #endif |
Geremia | 0:75ec1b3cde17 | 48 | _DC = 1; // 1=data |
Geremia | 0:75ec1b3cde17 | 49 | _WR=0; |
Geremia | 0:75ec1b3cde17 | 50 | _port.write(data8); // write 8bit |
Geremia | 0:75ec1b3cde17 | 51 | _WR=1; |
Geremia | 0:75ec1b3cde17 | 52 | #ifdef USE_CS |
Geremia | 0:75ec1b3cde17 | 53 | _CS = 1; |
Geremia | 0:75ec1b3cde17 | 54 | #endif |
Geremia | 0:75ec1b3cde17 | 55 | } |
Geremia | 0:75ec1b3cde17 | 56 | void PAR8::wr_data8(unsigned char data8, unsigned int count) |
Geremia | 0:75ec1b3cde17 | 57 | { |
Geremia | 0:75ec1b3cde17 | 58 | #ifdef USE_CS |
Geremia | 0:75ec1b3cde17 | 59 | _CS = 0; |
Geremia | 0:75ec1b3cde17 | 60 | #endif |
Geremia | 0:75ec1b3cde17 | 61 | _DC = 1; // 1=data |
Geremia | 0:75ec1b3cde17 | 62 | _port.write(data8); // write 8bit |
Geremia | 0:75ec1b3cde17 | 63 | while(count) |
Geremia | 0:75ec1b3cde17 | 64 | { |
Geremia | 0:75ec1b3cde17 | 65 | _WR=0; |
Geremia | 0:75ec1b3cde17 | 66 | // _WR=0; |
Geremia | 0:75ec1b3cde17 | 67 | _WR=1; |
Geremia | 0:75ec1b3cde17 | 68 | count--; |
Geremia | 0:75ec1b3cde17 | 69 | } |
Geremia | 0:75ec1b3cde17 | 70 | #ifdef USE_CS |
Geremia | 0:75ec1b3cde17 | 71 | _CS = 1; |
Geremia | 0:75ec1b3cde17 | 72 | #endif |
Geremia | 0:75ec1b3cde17 | 73 | } |
Geremia | 0:75ec1b3cde17 | 74 | void PAR8::wr_data8buf(unsigned char* data8, unsigned int lenght) |
Geremia | 0:75ec1b3cde17 | 75 | { |
Geremia | 0:75ec1b3cde17 | 76 | #ifdef USE_CS |
Geremia | 0:75ec1b3cde17 | 77 | _CS = 0; |
Geremia | 0:75ec1b3cde17 | 78 | #endif |
Geremia | 0:75ec1b3cde17 | 79 | _DC = 1; // 1=data |
Geremia | 0:75ec1b3cde17 | 80 | while(lenght) |
Geremia | 0:75ec1b3cde17 | 81 | { |
Geremia | 0:75ec1b3cde17 | 82 | _WR=0; |
Geremia | 0:75ec1b3cde17 | 83 | _port.write(*data8++); // write 8bit |
Geremia | 0:75ec1b3cde17 | 84 | _WR=1; |
Geremia | 0:75ec1b3cde17 | 85 | lenght--; |
Geremia | 0:75ec1b3cde17 | 86 | } |
Geremia | 0:75ec1b3cde17 | 87 | #ifdef USE_CS |
Geremia | 0:75ec1b3cde17 | 88 | _CS = 1; |
Geremia | 0:75ec1b3cde17 | 89 | #endif |
Geremia | 0:75ec1b3cde17 | 90 | } |
Geremia | 0:75ec1b3cde17 | 91 | void PAR8::hw_reset() |
Geremia | 0:75ec1b3cde17 | 92 | { |
Geremia | 0:75ec1b3cde17 | 93 | wait_ms(15); |
Geremia | 0:75ec1b3cde17 | 94 | _DC = 1; |
Geremia | 0:75ec1b3cde17 | 95 | _CS = 1; |
Geremia | 0:75ec1b3cde17 | 96 | _WR = 1; |
Geremia | 0:75ec1b3cde17 | 97 | _RD = 1; |
Geremia | 0:75ec1b3cde17 | 98 | _reset = 0; // display reset |
Geremia | 0:75ec1b3cde17 | 99 | wait_us(50); |
Geremia | 0:75ec1b3cde17 | 100 | _reset = 1; // end reset |
Geremia | 0:75ec1b3cde17 | 101 | wait_ms(15); |
Geremia | 0:75ec1b3cde17 | 102 | #ifndef USE_CS |
Geremia | 0:75ec1b3cde17 | 103 | _CS=0; // put CS low now and forever |
Geremia | 0:75ec1b3cde17 | 104 | #endif |
Geremia | 0:75ec1b3cde17 | 105 | } |
Geremia | 0:75ec1b3cde17 | 106 | void PAR8::BusEnable(bool enable) |
Geremia | 0:75ec1b3cde17 | 107 | { |
Geremia | 0:75ec1b3cde17 | 108 | _CS = enable ? 0:1; |
Geremia | 0:75ec1b3cde17 | 109 | } |